当设置参数mySubscribers=true时,YouTube API v3将返回所有频道列表查询的subscriberCount值为0。如果使用可选的"channelId"或"mine"参数,则subscriberCount是准确的。
下面是对文档的引用:https://developers.google.com/youtube/v3/docs/channels/list
为了简单地获取通道信息,我将部分设置为id和statistics。这是(测试版)api的bug吗?
我有同样的问题,现在这个指标你可以使用YouTube数据API v2,像这样:
http://gdata.youtube.com/feeds/api/users/{USER-ID-OR-USERNAME}?v=2&alt=json
并从yt$statistics->subscriberCount
这对我来说很有效。你在验证吗?如果您设置mySubscribers=true,而不设置mine=true(如果两者都设置为true,则会出现错误),您应该得到一个列表。在这个列表中应该有一个pageInfo -> totalResults,它应该告诉你这个数字。
下面是一个API资源管理器正确调用的例子(https://developers.google.com/youtube/v3/docs/channels/list #试一试):https://www.googleapis.com/youtube/v3/channels?part=id%2Cstatistics& mySubscribers = true&关键= {YOUR_API_KEY}
授权:承载ya29.blahblahX-JavaScript-User-Agent: Google api Explorer
Get Subscribers count by following way using V3 api
URLString =[NSString stringWithFormat:@"https://www.googleapis.com/youtube/v3/channels?part=id&mySubscribers=true&access_token=%@",accessToken]
Response
etag = ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/0_NpYsUUR0M4UrddABQ5GlAx0aA"";
items = (
{
etag = ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/I5mDLVKzrHCsmda5ZyJOe_6dhQ0"";
id = uhjUCDMMDlm9PwDGiMdfV7QeIRgasd;
kind = "youtube#channel";
},
{
etag = ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/kUNuk7bhfC8iuWaAUvnBzbv3ZdM"";
id = hjvhUCdMacPC0kNs1h3O1amJ2Mdwnv;
kind = "youtube#channel";
}
);
kind = "youtube#channelListResponse";
pageInfo = {
resultsPerPage = 5;
totalResults = 3; ////// Subscribers Count
};
}