使用YouTube API通过ID检索并显示YouTube视频描述,标题 [英] Retrieve and display YouTube video description, title by its id using YouTube API

查看:489
本文介绍了使用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'];
?>

这篇关于使用YouTube API通过ID检索并显示YouTube视频描述,标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆