【发布时间】:2017-01-21 13:59:05
【问题描述】:
所以我向具有以下范围的 youtube 分析发出请求:
'scope' => 'https://www.googleapis.com/auth/yt-analytics.readonly https://gdata.youtube.com https://www.googleapis.com/auth/userinfo.profile'
使用我的访问令牌,我尝试获取上个月的频道订阅者列表,如下所示:
$command = 'curl -H "Authorization: Bearer ' . $access_token . '"https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DMINE&start-date=2016-07-01&end-date-2016-08-31&metrics=views&dimensions=day&sort=day';
exec($command, $result);
即使我成功获取了访问令牌并保存了用户的凭据,我从这个请求中得到的是这样的:
array(0) { }
没有任何错误。有谁知道为什么会发生这种情况。如果您需要更多详细信息,请询问我。我一直在解决这个问题,所以我真的需要快速帮助。欢迎任何帮助。谢谢大家的时间! 这是我在 APIs Explorer 中发出请求的结果:
{
"kind": "youtubeAnalytics#resultTable",
"columnHeaders": [
{
"name": "day",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "views",
"columnType": "METRIC",
"dataType": "INTEGER"
}
]
}
【问题讨论】:
-
您能否使用 API Explorer 提供相同的数据?我试过了,但我无法获得任何数据,因为我的帐户没有 YT 频道。但是,根据您的回复 - 它与 YouTube 分析 API 上指定的 response body 不同
-
@adjuremods 响应正文应该保存在 ["data"]=> 中(数组的其余部分来自我的项目)
-
不知道api explorer怎么用,我现在去看看
-
我在 api explorer 中使用相同的参数执行它我用响应更新了我的问题
-
我编辑了我的回复的实际样子
标签: youtube-api youtube-data-api youtube-analytics youtube-analytics-api