Php Youtube分析API人口统计维度“;性别“;在分析仪表板上显示,但在API资源管理器上给出的查询无效
我目前正在使用Youtube分析API 到目前为止,我已经能够提取youtube提供的所有数据,除了性别/年龄组维度,每次查询都失败 这一点的例子播放位置,而不是人口统计它的自我 我用的是 ==PHP==Php Youtube分析API人口统计维度“;性别“;在分析仪表板上显示,但在API资源管理器上给出的查询无效,php,youtube,youtube-api,google-api-php-client,youtube-analytics,Php,Youtube,Youtube Api,Google Api Php Client,Youtube Analytics,我目前正在使用Youtube分析API 到目前为止,我已经能够提取youtube提供的所有数据,除了性别/年龄组维度,每次查询都失败 这一点的例子播放位置,而不是人口统计它的自我 我用的是 ==PHP== $analytics_gender = new Google_YouTubeAnalyticsService($client); $optparam = array('dimensions' => 'gender'); $metrics= "views"; $analytics_d
$analytics_gender = new Google_YouTubeAnalyticsService($client);
$optparam = array('dimensions' => 'gender');
$metrics= "views";
$analytics_demo_gender = $analytics_gender->reports->query("channel==".$channelId, "2012-08-14", "2013-05-30", $metrics, $optparam);
当我运行此查询时,我得到一个
错误(400),该查询不受支持。
即使它对所有其他度量和维度都正常工作。性别维度只能与度量viewerPercentage
(如果您愿意,还可以选择使用国家/地区和/或视频过滤器以及附加的年龄组
维度)。您可以搜索“性别”以查看确切的规格
API Explorer中的工作报告。进行身份验证,并用频道ID替换频道ID。执行此操作很简单,请查看下面的代码片段以查找人口统计和性别统计信息:
request.get({
url:'https://www.googleapis.com/youtube/analytics/v1/reports?key={Google Api Key}&ids=channel=={channelId}&dimensions=country&metrics=views&end-date={endDate}&start-date={startDate}',
json:true,
timeout: 10000,
headers:{'Authorization':'Bearer '+accessToken}},
function (err,r,result) {
console.log(result)
});
如果您需要在下面查找性别信息,可以使用代码段:
request.get({
url:'https://www.googleapis.com/youtube/analytics/v1/reports?key={Google Api Key}&ids=channel=={channelId}&dimensions=gender&metrics=viewerPercentage&end-date={endDate}&start-date={startDate}',
json:true,
timeout: 10000,
headers:{'Authorization':'Bearer '+accessToken}},
function (err,r,result) {
console.log(result)
});
如果您需要在下面查找性别信息和年龄组,可以使用代码段
request.get({
url:'https://www.googleapis.com/youtube/analytics/v1/reports?key={Google Api Key}&ids=channel=={channelId}&dimensions=gender,ageGroup&metrics=viewerPercentage&end-date={endDate}&start-date={startDate}',
json:true,
timeout: 10000,
headers:{'Authorization':'Bearer '+accessToken}},
function (err,r,result) {
console.log(result)
});
为支持干杯:DI没有得到任何响应数据,即使没有错误。请你有什么想法吗?欢迎使用StackOverflow。请使用缩进而不是
块:后者不提供语法highlightning,就像我在建议的编辑中所做的那样。祝你好运。