1

I used GAPI http://code.google.com/p/gapi-google-analytics-php-interface/ so far to get some data out of Google Analytics with PHP. With that you could use something like:

$ga = new gapi($User, $Password);

to login to Analytics and pull the data very easy.

But now the GAPI-Support has been canceled, and you have to use https://developers.google.com/analytics/devguides/reporting/core/v3/ to access the data. But on all examples they use a method where the user has to do the login in a webbrowser to gain access. But I have a script on a webserver and I only have $User and $Password... So could someone please give me an example on how to do authenticate the user with that in PHP?

jk.
  • 14,365
  • 4
  • 43
  • 58
Werner
  • 1,695
  • 3
  • 21
  • 42

1 Answers1

1

OAuth has a flow called Client Credentials Grant. Google implements this with so called Service Accounts, where you get a client ID and a certificate file instead of a username/password combination.

For using a Service Account to request authorization to the Google Analytics API, just follow this answer.

Community
  • 1
  • 1
Jan Gerlinger
  • 7,361
  • 1
  • 44
  • 52