Php 通过谷歌分析API获取AdSense数据
根据(相当复杂的)文档,我已经在我的Laravel应用程序中成功地实现了Google Analytics API。创建此metrics对象时,我从服务器获得响应,没有问题:Php 通过谷歌分析API获取AdSense数据,php,laravel,google-analytics,google-api,Php,Laravel,Google Analytics,Google Api,根据(相当复杂的)文档,我已经在我的Laravel应用程序中成功地实现了Google Analytics API。创建此metrics对象时,我从服务器获得响应,没有问题: $sessions = new Google_Service_AnalyticsReporting_Metric(); $sessions->setExpression("ga:sessions"); 但是,这是我需要的数据: 因此,我想我需要一些其他指标来获取我需要的数据,我在官方网站上搜索了与源代码相关的任何内
$sessions = new Google_Service_AnalyticsReporting_Metric();
$sessions->setExpression("ga:sessions");
但是,这是我需要的数据:
因此,我想我需要一些其他指标来获取我需要的数据,我在官方网站上搜索了与源代码
相关的任何内容,但无论我从列表中使用了什么,我都会得到以下响应:
"""
{\n
"error": {\n
"code": 400,\n
"message": "Unknown metric(s): ga:source\nFor details see https://developers.google.com/analytics/devguides/reporting/core/dimsmets.",\n
"errors": [\n
{\n
"message": "Unknown metric(s): ga:source\nFor details see https://developers.google.com/analytics/devguides/reporting/core/dimsmets.",\n
"domain": "global",\n
"reason": "badRequest"\n
}\n
],\n
"status": "INVALID_ARGUMENT"\n
}\n
}\n
"""
是否有办法获取所需的数据?如果有人需要答案,我已使用以下方法解决:
//Create the Dimensions object.
$dimensions = new Google_Service_AnalyticsReporting_Dimension();
$dimensions->setName("ga:source");
如果有人想要答案,我已使用以下方法解决:
//Create the Dimensions object.
$dimensions = new Google_Service_AnalyticsReporting_Dimension();
$dimensions->setName("ga:source");