I'm trying to migrate the old google api to the new one, so I can get the google analytics data. I'm trying with this example, but it fires this error
Fatal error: Class 'Google_Auth_AssertionCredentials' not found in example.php
This is how I'm trying:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once 'google-api-php-client/vendor/autoload.php';
//$p12FilePath = '/path/to/key.p12';
$serviceClientId = '395545742105.apps.googleusercontent.com';
$serviceAccountName = '395545742105@developer.gserviceaccount.com';
$scopes = array(
'https://www.googleapis.com/auth/analytics.readonly'
);
$googleAssertionCredentials = new Google_Auth_AssertionCredentials(
$serviceAccountName,
$scopes
); // <- Fatal error here
$client = new Google_Client();
$client->setAssertionCredentials($googleAssertionCredentials);
$client->setClientId($serviceClientId);
$client->setApplicationName("Project");
$analytics = new Google_Service_Analytics($client);
And I did run a search for Google_Auth_AssertionCredentials in the library wich I download from here, and Just one result: upagrading.md
Google_Auth_AssertionCredentials removed use Google_Client::setAuthConfig instead,
But how should I use it in a contructor?
I tred
$googleAssertionCredentials = new Google_Client::setAuthConfig(
$serviceAccountName,
$scopes
);
With internal server error,
Any idea what I'm missing here?