如何从 youtube google api 访问 youtube json 日期?

How to access youtube json date from the youtube google api?

我怎样才能访问像 url 这样的东西,比如横幅图片、频道标题、订阅者数量,以及来自 youtube google 的 url 的默认徽标图片 url =21=] 用于 Youtube?

一个example of the JSON api can be found here.

如何使用 PHP 访问此内容?

这个简单的片段应该可以解决问题。

$myData = json_decode(file_get_contents("https://www.googleapis.com/youtube/v3/channels?part=snippet,brandingSettings&id=UCyoUx3RguJRgbaMo07yc_KA&key=AIzaSyCZonTWlCv92Nd93j5CuFFcqGciLIe5rx4"));
var_dump($myData);

出于性能原因,我真的建议使用 cURL 而不是 file_get_contents(),但是这应该可以帮助您入门。

以这种方式进行:

$youtube = file_get_contents("https://www.googleapis.com/youtube/v3/channels?part=snippet,brandingSettings&id=UCyoUx3RguJRgbaMo07yc_KA&key=AIzaSyCZonTWlCv92Nd93j5CuFFcqGciLIe5rx4");

$data = json_decode($youtube,true);

echo "BANNER IMAGE URL: ".$data['items'][0]['brandingSettings']['image']['bannerImageUrl']."<br>";
echo "CHANNEL TITLE: ".$data['items'][0]['brandingSettings']['channel']['title']."<br>";

等等....

this tools 很好看一个json的结构,提取你需要的