Get simple video data from youtube api and json decode into cakephp 1.3

advertisements

Ever since Google changed YouTube to API3.0 I can't fetch videos anymore. I can't get video id and api key to apiURL

$video_id = // I stript it from url
$apiKey = Configure::read('YouTube.v3.0.privateKey'); // hidden in bootstrap

$apiURL = 'https://www.googleapis.com/youtube/v3/videos?id=$video_id&key=$apiKey';

and on debug($apiURL); I'm getting

https://www.googleapis.com/youtube/v3/videos?id=$video_id&key=$apiKey

anyone can help? Thanks in Advance.


if you want little snippet, here we go, it works for me on cakephp1.3 application

$apiURL = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=snippet&id={$video_id}&key={$apiKey}");

$youtubeResponse = json_decode($apiURL, true);

$youtube_data = $youtubeResponse['items'];
// debug($youtube_data);

$youtube_data_title =  $youtube_data['0']['snippet']['title'];
$youtube_data_description = $youtube_data['0']['snippet']['description'];
$youtube_data_thumbnail = $youtube_data['0']['snippet']['thumbnails']['default']['url'];

    $this->set('youtube_data_title', $youtube_data_title);
    $this->set('youtube_data_description', $youtube_data_description);
    $this->set('youtube_data_thumbnail', $youtube_data_thumbnail);