沃梦达 / 编程问答 / php问题 / 正文

使用 YouTube API 通过其 ID 检索和显示 YouTube 视频描述、标题

Retrieve and display YouTube video description, title by its id using YouTube API(使用 YouTube API 通过其 ID 检索和显示 YouTube 视频描述、标题)

本文介绍了使用 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 视频描述、标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:使用 YouTube API 通过其 ID 检索和显示 YouTube 视频描述、标题

基础教程推荐