private function getCachedJsonResponse($url)
    {
        if (!class_exists('GuzzleHttp\Client')) {
            return false;
        }

        $cache_seconds = $this->config()->get('cache_seconds');
        if (!is_numeric($cache_seconds)) {
            $cache_seconds = 604800;
        }

        $cache = Injector::inst()->get(CacheInterface::class . '.videoImgCache');

        $key = md5($url);

        if (!$json = $cache->get($key)) {
            $client = new \GuzzleHttp\Client([
                'timeout' => 5, // seconds
                'headers' => [ // Appear like a web browser
                    'User-Agent'      => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0',
                    'Accept-Language' => 'en-US,en;q=0.5',
                ],
            ]);
            try {
                $res = $client->request('GET', $url);
                $json = (string) $res->getBody();
            } catch (\GuzzleHttp\Exception\RequestException $e) {
                return false;
            }
            $cache->set($key, $json, $cache_seconds);
        }

        $data = @json_decode($json, true);
        return (!empty($data)) ? $data : false;
    }
private function getCachedJsonResponse($url)
    {
        if (!class_exists('GuzzleHttp\Client')) {
            return false;
        }

        $cache_seconds = $this->config()->get('cache_seconds');
        if (!is_numeric($cache_seconds)) {
            $cache_seconds = 604800;
        }

        $cache = Injector::inst()->get(CacheInterface::class . '.videoImgCache');

        $key = md5($url);

        if (!$json = $cache->get($key)) {
            $client = new \GuzzleHttp\Client([
                'timeout' => 5, // seconds
                'headers' => [ // Appear like a web browser
                    'User-Agent'      => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0',
                    'Accept-Language' => 'en-US,en;q=0.5',
                ],
            ]);
            try {
                $res = $client->request('GET', $url);
                $json = (string) $res->getBody();
            } catch (\GuzzleHttp\Exception\RequestException $e) {
                return false;
            }
            $cache->set($key, $json, $cache_seconds);
        }

        $data = @json_decode($json, true);
        return (!empty($data)) ? $data : false;
    }
private function getCachedJsonResponse ( $ url ) { if ( ! class_exists ( 'GuzzleHttp\Client' ) ) { return false ; } $ cache_seconds = $ this -> config ( ) -> get ( 'cache_seconds' ) ; if ( ! is_numeric ( $ cache_seconds ) ) { $ cache_seconds = 604800 ; } $ cache = Injector :: inst ( ) -> get ( CacheInterface :: class . '.videoImgCache' ) ; $ key = md5 ( $ url ) ; if ( ! $ json = $ cache -> get ( $ key ) ) { $ client = new \ GuzzleHttp \ Client ( [ 'timeout' => 5 , // seconds 'headers' => [ // Appear like a web browser 'User-Agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0' , 'Accept-Language' => 'en-US,en;q=0.5' , ] , ] ) ; try { $ res = $ client -> request ( 'GET' , $ url ) ; $ json = ( string ) $ res -> getBody ( ) ; } catch ( \ GuzzleHttp \ Exception \ RequestException $ e ) { return false ; } $ cache -> set ( $ key , $ json , $ cache_seconds ) ; } $ data = @ json_decode ( $ json , true ) ; return ( ! empty ( $ data ) ) ? $ data : false ; }
Return cached json response

@param  String url
@return Array|null
Return cached json response