Php Google API总是返回0或1,永远不会再返回更多
我已经连接到谷歌分析APIPhp Google API总是返回0或1,永远不会再返回更多,php,google-analytics-api,Php,Google Analytics Api,我已经连接到谷歌分析API “谷歌/apiclient”:“2.7.2” 所有数据都正确提供,如ga:users或ga:pagePath 但最近创建了一项新服务,允许我在页面上查看“实时用户”,该服务从data\u realtime收集数据,但问题是,当当前页面上的no1 Google Analytics API返回正确的0,但当有流量时,它总是返回1,ofc我确信有不止一个用户(分析面板显示更多)。有什么想法可能是错误的吗 这是我的密码: class LiveUsersService扩展了Ab
“谷歌/apiclient”:“2.7.2”
所有数据都正确提供,如ga:users
或ga:pagePath
但最近创建了一项新服务,允许我在页面上查看“实时用户”,该服务从data\u realtime
收集数据,但问题是,当当前页面上的no1 Google Analytics API返回正确的0
,但当有流量时,它总是返回1
,ofc我确信有不止一个用户(分析面板显示更多)。有什么想法可能是错误的吗
这是我的密码:
class LiveUsersService扩展了AbstractGoogleAnalyticsService
{
公共函数getResult(数组$params=[]):int
{
$params=array_merge($params,$this->getRequiredParams());
$results=$this->googleAnalyticsService
->getAnalytics()
->数据实时
->得到(
“ga:”。$this->googleAnalyticsService->getProfileId(),
'rt:activeUsers',
$params
);
返回$this->parse($results);
}
受保护的函数getRequiredParams():数组
{
返回[
'dimensions'=>'rt:userType',
];
}
受保护的函数解析(\Google\u Service\u Analytics\u RealtimeData$result):int
{
返回$result->getTotalResults();
}
}
getTotalResults是返回的总行数,而不是实际结果。