1

我用這個代碼,直到昨天:谷歌分析API認證

$gaemail = 'my email'; 
$gapassword = 'my password'; 
$gaprofileid = 'my profile id'; 

require 'gapi.php'; 

$ga = new gapi($gaemail,$gapassword); 

如今,它開始給我的錯誤:

異常:GAPI:無法驗證用戶。

錯誤: 「https://developers.google.com/accounts/docs/AuthForInstalledApps」 在C:\ WAMP \ WWW \項目\ gapi.php上線418

是否有任何變化最近關於認證過程?

+0

此問題是由於身份驗證方法(ClientLogin to OAuth)的更改所致。按照https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-php?hl=pt-br中的說明解決了我的問題。希望能幫助到你。 –

回答

0

請參見:GAPI: Failed to authenticate user. Permanent fix PHP

GAPI hasn't been worked on since 2009. It also appears to use client login which was discontinued/shutdown on April 20 2015. You can no longer use client login with Google Analytics API, you need to switch to Oauth2 or a service account. So either the author of that project needs to fix his code, it appears to be an open source project so you could probably fix it for him.

你有一對夫婦的選擇。看起來像最新版本的GAPI現在有oauth支持 - 請參閱:https://github.com/erebusnz/gapi-google-analytics-php-interface或使用Google API PHP客戶端https://github.com/google/google-api-php-client)。

+0

感謝您的回覆,我使用github提供的gapi.php和上面提到的認證StigM,它解決了我的問題。 –

0

Version 2.0 on GitHub GAPI已發佈,支持OAuth2身份驗證。 Google已禁用所有其他形式的身份驗證。

請注意,OAuth2將要求您登錄create a 'service account',然後下載P12文件以上傳到服務器。最後,您需要調整開發者控制檯,啓用「分析API」。最後,爲您希望訪問的Google Analytics帳戶授予此新用戶的「讀取和分析」權限。