2013-04-10 70 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,即 。

如果您在帳戶中啓用了兩步驗證,則應嘗試訪問代碼解決方法,否則應聯繫圖書館開發人員並建議他們放棄已棄用的授權方法。