dongluo8439
2015-04-07 15:41
浏览 42
已采纳

PHP上的Google AnalyticsAPI

But still I got this issue:

Fatal error: Uncaught exception 'Google_Exception' with message '(get) missing required param: 'ids'' in /home/sample/www/test/google-api-php-client-master/src/Google/Service/Resource.php:163 Stack trace: #0 /home/sample/www/test/google-api-php-client-master/src/Google/Service/Analytics.php(2107): Google_Service_Resource->call('get', Array, 'Google_Service_...') #1 /home/sample/www/test/google-api-php-client-master/practicein.php(57): Google_Service_Analytics_DataRealtime_Resource->get('ga:********', 'ga:pageviews', '2015-03-07', '2015-04-04') #2 /home/sample/www/test/index.php(34): require_once('/home/lanforest...') #3 {main} thrown in /home/sample/www/test/google-api-php-client-master/src/Google/Service/Resource.php on line 163

And I think the codes around here is wrong.

$results = $analytics->data_realtime->get(
    $analytics_view_id,
    'ga:pageviews',//**I did correct this.**
    '2015-03-07',
    '2015-04-04'
);

//**I think these goes wrong**
$totals = $results->getTotalsForAllResults();
$array = array("activeUsers" => $totals["rt:activeUsers"]);

I want to see just page views. What can I code?

I think I got active user value.But,It still warning. What kind of error is this?

Warning: Cannot modify header information - headers already sent by (output started at /home/sample/www/test/index.php:16) in /home/sample/www/test/google-api-php-client-master/practicein.php on line 76

Warning: Cannot modify header information - headers already sent by (output started at /home/sample/www/test/index.php:16) in /home/sample/www/test/google-api-php-client-master/practicein.php on line 77

{"activeUsers":"0"}//this is the result.

图片转代码服务由CSDN问答提供 功能建议

但我仍然遇到此问题:

致命 错误:/home/sample/www/test/google-api-php-client-master/src/Google/Service/Resource.php中未捕获的异常'Google_Exception',消息'(get)缺少必需的参数:'ids'' :163堆栈跟踪:#0 /home/sample/www/test/google-api-php-client-master/src/Google/Service/Analytics.php(2107):Google_Service_Resource-> call('get',Array ,'Google_Service _...')#1 /home/sample/www/test/google-api-php-client-master/practicein.php(57):Google_Service_Analytics_DataRealtime_Resource-> get('ga:***** ***','ga:pageviews','2015-03-07','2015-04-04')#2 /home/sample/www/test/index.php(34):require_once('/ home / lanforest ...')#3 {main}投放在/home/sample/www/test/google-api-php-client-master/src/Google/Service/Resource.php第163行 \ n

我认为这里的代码是错误的。

  $ results = $ analytics-> data_realtime-> get(  
 $解析 s_view_id,
'ga:pageviews',// **我确实纠正了这个问题。** 
'2015-03-07',
'2015-04-04'
); 
 
 //  **我认为这些出错了** 
 $ totals = $ results-> getTotalsForAllResults(); 
 $ array = array(“activeUsers”=>  $ totals [“rt:activeUsers”]); 
   
 
 

我想看到页面浏览量。 我可以编码什么?

我认为我有活跃的用户价值。但是,它仍然警告。 这是什么类型的错误?

 < 代码>警告:无法修改标题信息 - 已经发送的标题(/ home / sample / www / test / google-api-php-client-中的/home/sample/www/test/index.php:16开始输出) 第76行的master / practicein.php 
 
警告:无法修改标题信息 - 已在/ home / sample / www / test中发送的标题(/home/sample/www/test/index.php:16中的输出开始) 第77行上的/google-api-php-client-master/practicein.php 
 
 {“activeUsers”:“0”} //这就是结果。
   
 <  / DIV>
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题