I'm using Google's PHP client library to access the analytics API and I keep getting an error, Call to a member function on a non-object. I've been stumped for more than a day. I've read through several solutions, and I'm not seeing how to resolve this.
require_once "google-api-php-client/src/Google_Client.php";
require_once "google-api-php-client/src/contrib/Google_AnalyticsService.php";
session_start();
$client = new Google_Client();
$client->setApplicationName("app-name");
$client->setClientId('client-id');
$client->setClientSecret('my-secret');
$client->setRedirectUri('http://www.website.com/');
$client->setDeveloperKey('secret-key');
$analyticsService = new Google_AnalyticsService($client);
$dailyUploads = $analyticsService->dailyUploads;
This is (I think) the way that Google recommends to set this up, yet when I print out the contents of $dailyUploads its empty/null. If I print out $analyticsService I see the code of Google_AnalyticsService.
Later in my code, after authentication, I attempt to use the upload function like so:
$upload = $dailyUploads->upload($media);
This produces the error that I mentioned earlier, Fatal error: Call to a member function upload() on a non-object.
Can anyone help? What am I overlooking?