我不太确定如何询问此问题,但是我有一个PHP脚本,可以从YouTube-V3-API中为我的YouTube频道提取数据,主要是我的视频列表已经出版了。直到今天早些时候,我一直在运行它,因为我添加了一个新视频。这是项目数组中第一个对象的输出
items:[
{
kind:"youtube#searchResult",
etag:"" XpPGQXPnxQJhLgs6enD_n8JR4Qk/tluoWYe5GE9lVFAkcMtcec2Ycug"",
id:{
kind:"youtube#channel",
channelId:"UCD8d3FGC907iS1qiMF0ccxA"
},
snippet:{
publishedAt:"2006-04-30T19:39:08.000Z",
channelId:"UCD8d3FGC907iS1qiMF0ccxA",
title:"Travis Ballard",
description:"",
thumbnails:{
default:{
url:"https://yt3.ggpht.com/-L5MV7tUNjlk/AAAAAAAAAAI/AAAAAAAAAAA/dXNuqxAYprw/s88-c-k-no-mo-rj-c0xffffff/photo.jpg"
},
medium:{
url:"https://yt3.ggpht.com/-L5MV7tUNjlk/AAAAAAAAAAI/AAAAAAAAAAA/dXNuqxAYprw/s240-c-k-no-mo-rj-c0xffffff/photo.jpg"
},
high:{
url:"https://yt3.ggpht.com/-L5MV7tUNjlk/AAAAAAAAAAI/AAAAAAAAAAA/dXNuqxAYprw/s800-c-k-no-mo-rj-c0xffffff/photo.jpg"
}
},
channelTitle:"Travis Ballard",
liveBroadcastContent:"none"
}
}
]
这不代表我的频道上的视频?另外,这根本不是顺序的。我应该按日期订购,因为我在PHP脚本中要求它:
<?php
const APIKEY = 'MyAPIKeyHere';
const CHANNELID = 'UCD8d3FGC907iS1qiMF0ccxA';
const VIDEO_COUNT = 50;
class FetchYoutubeVideos {
private $api_key = null;
private $channel_id = null;
private $count = null;
public function __construct($api_key, $channel_id, $count = 10) {
$this->api_key = $api_key;
$this->channel_id = $channel_id;
$this->count = $count;
$this->writeToFile(
'videos.json',
$this->fetch($this->getApiUrl())
);
printf( 'fetched videos from: %s', $this->getApiUrl());
}
public function getApiUrl($options = array()) {
$endpoint = 'https://www.googleapis.com/youtube/v3/search';
$default_options = array(
'key' => $this->api_key,
'channelId' => $this->channel_id,
'part' => 'snippet,id',
'order' => 'date',
'maxResults' => $this->count
);
$options = array_merge($options, $default_options);
return sprintf('%s/?%s', $endpoint, http_build_query($options));
}
public function fetch($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
return $result;
}
public function writeToFile($filename, $data) {;
$fh = fopen($filename, 'w+');
fwrite($fh, $data, strlen($data));
fclose($fh);
}
}
$fetchVideos = new FetchYoutubeVideos(APIKEY, CHANNELID, VIDEO_COUNT);
最新的视频应该是"悲剧 - 摇滚 - 霍拉重新审视",然后是" Rocket Pimelapse -Any Cubic i3 Mega"。您可以参考我的YT频道以查看应该返回的内容:https://www.youtube.com/channel/channel/ucd8d3fgc907is1qimf0ccxa?view_view_as=subscriber
对为什么改变的任何见解?或者为什么它不返回应该返回的数据?
您遇到了一个API问题,该问题已经闻名了几天。后续https://issuetracker.google.com/issues/128673552或本网站上已经给出的答案(例如https://stackoverflow.com/a/555246970/8327971)
这两个链接中的任何一个我们都会带领您找到当前问题的解决方法。
请注意,到目前为止,Google避免提供ETA,以启用其禁用API的功能。我想这可能还需要几天(也许几周?),直到我们看到这些残疾人的功能再次起作用为止。