UpendraSingh / analytics-issues

Automatically exported from code.google.com/p/analytics-issues
0 stars 0 forks source link

Documentation: update example of working with Google Analytics Api for php language. #920

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
---------------------------------------------------------------------------
NOTE: This tool is not designed to request help. It is only for reporting
issues and requesting features for the Google Analytics libraries.

If you are a developer and you need help, visit:
https://developers.google.com/analytics/help/

If you are not a developer and you need help, visit:
https://support.google.com/analytics
---------------------------------------------------------------------------
Name of affected component: Analytics Core Reporting API

https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/s
ervice-php

Issue summary:
The php example for working with Google Analytics Service does not work. Since 
the code was updated, then the class "Google_Auth_AssertionCredentials" does 
not exist. And the method "setAssertionCredentials" has been removed from the 
class "Google_Client".

I suggest to use the following code:

$client = new Google_Client();
$client->setApplicationName("helloAnalytics");
$client->setAuthConfig("service-account-credentials.json");
$client->setScopes('https://www.googleapis.com/auth/analytics.readonly');
$service = new Google_Service_Analytics($client);

As you can see in this example used json config file instead p12 file. I 
suggest to use this example, because at the stage of creating the key 
recommended choosing json format. Consequently, it would be helpful to more 
people.

Original issue reported on code.google.com by tech...@lazada.com on 24 Mar 2016 at 12:31

GoogleCodeExporter commented 8 years ago
The Hello Analytics PHP example is currently implemented to work with branch 
v1-master v2/master branch is still underdevelopment once stabilized the 
HelloAnalytics.php example will be updated.

Original comment by mcoh...@google.com on 24 Mar 2016 at 3:22