Retrieve and display YouTube video description, ti

2019-02-20 17:30发布

I would like to display on a page the title and description of a video youtube, I know how do this for count number with this php code

<?php
$JSON = file_get_contents("https://www.googleapis.com/youtube/v3/videos?
part=statistics&id=videoID&key=APIKey");
$json_data = json_decode($JSON, true);
echo $json_data['items'][0]['statistics']['viewCount'];
?>

But i don't know how do this do display video title and description.

1条回答
Viruses.
2楼-- · 2019-02-20 18:13
<?php
$JSON = file_get_contents("https://www.googleapis.com/youtube/v3/videos?
part=snippet&id=videoID&key=APIKey");
$json_data = json_decode($JSON, true);
echo $json_data['items'][0]['snippet']['title'];
echo $json_data['items'][0]['snippet']['description'];
?>
查看更多
登录 后发表回答