2013-04-10 68 views
1

Google上有很多结果,但其中大部分都是一年多的。Google analytics integration codeigniter

我以前this library 但我有一个错误,当我登录:

一个错误时遇到

谷歌Analytics(分析)API库:的GData authError AuthorizationInvalid 证书

我控制器代码是:

$this->load->library('ga_api'); 
$this->ga_api->login(); 
$data['google'] = $this->ga_api 
->dimension('adGroup , campaign , adwordsCampaignId , adwordsAdGroupId') 
->metric('impressions') 
->limit(30) 
->get_object(); 

$this->load->view('includes/template', $data); 
+0

您是否已在“config/ga_api.php”文件中正确设置了凭据? – swatkins 2013-04-10 15:53:51

+0

http://stackoverflow.com/questions/25668009/google-analytis-api-on-codeigniter-website – 2015-08-28 12:16:04

回答

0

看来你有身份验证问题,所以你的API应该注册谷歌,你会忘了嘛一些权威性的访问,我在图书馆DOC发现是:

// Set new profile id if not the default id within your config document 
$this->ga = $this->ga_api->login()->init(array('profile_id' => '182918291281')); 

我猜你需要的API密钥或使用profile_id,如在此示例中

1

我检查了该库,它似乎在使用Google Analytics(分析)中的报告API的第2版。这个API有一个新的v3版本。

而对于授权,它使用ClientLogin。从ClientLogin docs

重要:ClientLogin用户已经officially deprecated截至2012年4月20日将继续按照我们的deprecation policy工作,但我们建议您尽快 地迁移到OAuth 2.0

重要:如果您的客户正与ClientLogin的麻烦,他们的帐户可能无法使用的可能原因的各种 与之兼容。例如,使用两步 验证,SAML或Open ID的帐户与ClientLogin不兼容。 一种解决方法是告诉用户生成一个由access codes提供的一次性密码 ,该密码允许他们在Web浏览器中登录其 帐户并生成一个长密码,他们可以将 键入到任何密码字段中使用ClientLogin的应用程序。 A 更好的解决方案是将您的应用转换为使用与所有现有Google帐户兼容的OAuth 2.0,即 。

如果您在帐户中启用了两步验证,则应尝试访问代码解决方法,否则应联系图书馆开发人员并建议他们放弃已弃用的授权方法。