使用 YouTube API 通过其 ID 检索和显示 YouTube 视频描述、标题
我想在页面上显示视频 youtube 的标题和描述,我知道如何使用这个 php 代码来计算计数
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.
推荐答案
<?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'];
?>
相关文章