title: Google Analytics API in PHP backend
body: <p>So I want to display GA chart in custom PHP backend. So I created APP in <a href="https://console.developers.google.com/" rel="nofollow">https://console.developers.google.com/</a> but I cant figure out how to access <strong>my own</strong> google analytics data withouth asking for user to login. For now I have simple code:</p>
  
  <pre><code>  $client = new Google_Client();
    $client-&gt;setApplicationName("App Name");
    $client-&gt;setClientId(CLIENT_ID);
    $client-&gt;setClientSecret(CLIENT_SECRET);
    $client-&gt;setDeveloperKey(APP_ID);
    $client-&gt;setScopes(array('https://www.googleapis.com/auth/analytics.readonly'));
    $client-&gt;authenticate();
    $token = $client-&gt;getAccessToken();
    $service = new Google_Service_Analytics($client);
  $optParams = array(
        'sort' =&gt; 'ga:pageviews',
        'max-results' =&gt; '5');
  $results = $service-&gt;data_ga-&gt;get(
         'ga:123456',
         '2015-01-01',
         '2015-01-30',
         'ga:pagePath',
         $optParams);
  
  print_r($results);
  </code></pre>
  
  <p>I guess I am doing everything wrong :), so my question would be, how to allow anyone to access my own google analytics data through PHP script?</p>