2016-04-06 08:36
浏览 53

Auth Google Analytics PHP API

I have tried the official HelloAnalytics tutorial however it doesn't work.

I am recieveing this error:

"PHP Fatal error: Class 'Google_Auth_AssertionCredentials' not found"

My Code:

  // Creates and returns the Analytics service object.

  // Load the Google API PHP Client Library.
   require_once 'vendor/autoload.php';

  // Use the developers console and replace the values with your
  // service account email, and relative location of your key file.
  $service_account_email = '';
   $key_file_location = 'key_anyl.p12';

 // Create and configure a new client object.
  $client = new Google_Client();
   $analytics = new Google_Service_Analytics($client);

 // Read the generated client_secrets.p12 key.
  $key = file_get_contents($key_file_location);
  $cred = new Google_Auth_AssertionCredentials(
   if($client->getAuth()->isAccessTokenExpired()) {


after adding the suggested V1-master branch I am now getting the following error

Uncaught exception 'Google_Service_Exception' with message 'Error calling GET (403) User does not have any Google Analytics account.'

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题