剛好網路上有個範例~~
就稍微整理一下
這些資料是我要用的~~所以就貼出來怎麼取這些data
$videoID = 'Win3q-_zygc';
$JSON = file_get_contents("http://gdata.youtube.com/feeds/api/videos/".$videoID."?v=2&alt=json");
$JSON_Data = json_decode($JSON);
print '<pre>';
print_r($JSON_Data);
print '</pre>';
$youTubeTitle = $JSON_Data->{'entry'}->{'title'}->{'$t'};
$youtubeDescription = $JSON_Data->{'entry'}->{'media$group'}->{'media$description'}->{'$t'};
$youtubeViewsCount = $JSON_Data->{'entry'}->{'yt$statistics'}->{'viewCount'};
$youtubeAuthor = $JSON_Data->{'entry'}->{'author'}[0]->{'name'}->{'$t'};
$youtubePublished = strtotime($JSON_Data->{'entry'}->{'published'}->{'$t'});
reference$JSON = file_get_contents("http://gdata.youtube.com/feeds/api/videos/".$videoID."?v=2&alt=json");
$JSON_Data = json_decode($JSON);
print '<pre>';
print_r($JSON_Data);
print '</pre>';
$youTubeTitle = $JSON_Data->{'entry'}->{'title'}->{'$t'};
$youtubeDescription = $JSON_Data->{'entry'}->{'media$group'}->{'media$description'}->{'$t'};
$youtubeViewsCount = $JSON_Data->{'entry'}->{'yt$statistics'}->{'viewCount'};
$youtubeAuthor = $JSON_Data->{'entry'}->{'author'}[0]->{'name'}->{'$t'};
$youtubePublished = strtotime($JSON_Data->{'entry'}->{'published'}->{'$t'});
http://stackoverflow.com/questions/3331176/how-to-get-number-of-video-views-with-youtube-api
沒有留言:
發佈留言