To view this discussion on the web visit https://groups.google.com/d/msg/google-analytics-data-export-api/-/rPZ3LGZYUD8J.--
You received this message because you are subscribed to the Google Groups "GA Data Export API" group.
To post to this group, send email to google-analytics...@googlegroups.com.
To unsubscribe from this group, send email to google-analytics-data-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-analytics-data-export-api?hl=en.
--
You received this message because you are subscribed to the Google Groups "GA Data Export API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-analytics-data-export-api/-/n3dLovbxnagJ.
To post to this group, send email to google-analytics...@googlegroups.com.
To unsubscribe from this group, send email to google-analytics-data-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-analytics-data-export-api?hl=en.
apiHttpRequest Object ( [batchHeaders:apiHttpRequest:private] => Array ( [Content-Type] => application/http [Content-Transfer-Encoding] => binary [MIME-Version] => 1.0 [Content-Length] => ) [url:protected] => https://accounts.google.com/o/oauth2/token [requestMethod:protected] => POST [requestHeaders:protected] => Array ( [content-type] => application/x-www-form-urlencoded [content-length] => 534 ) [postBody:protected] => grant_type=assertion&assertion_type=http%3A%2F%2Foauth.net%2Fgrant_type%2Fjwt%2F1.0%2Fbearer&assertion=quitealongstringtopaste [userAgent:protected] => Google Oauth2 Sample google-api-php-client/0.5.0 [responseHttpCode:protected] => 400 [responseHeaders:protected] => Array ( [cache-control] => no-cache, no-store, max-age=0, must-revalidate [pragma] => no-cache [expires] => Fri, 01 Jan 1990 00:00:00 GMT [date] => Sun, 27 May 2012 21:52:03 GMT [content-type] => application/json [x-content-type-options] => nosniff [x-frame-options] => SAMEORIGIN [x-xss-protection] => 1; mode=block [server] => GSE [transfer-encoding] => chunked ) [responseBody:protected] => { "error" : "invalid_grant" } [accessKey] =>
require_once("../_includes/config/header.php"); //contains the definitions of the following constants
require_once (G_API_DIR.'/src/apiClient.php');
require_once (G_API_DIR.'/src/contrib/apiOauth2Service.php');
$client = new apiClient();
$client->setApplicationName("Google Oauth2 Sample");
// Set your cached access token. Remember to replace $_SESSION with a real database or memcached.
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
$key = file_get_contents(G_KEY_FILE);
$cred = new apiAssertionCredentials(
G_SERVICE_ACCOUNT_NAME,
array(G_USER_PROFILE, G_USER_EMAIL),
$key
);
print '<h2>JWT:</h2><pre>' . print_r($cred->generateAssertion(), true) . '</pre>';
$client->setAssertionCredentials($cred);
$client->setClientId(G_CLIENT_ID);
$service = new apiOauth2Service($client);
$result = $service->userinfo->get();
print '<h2>Oauth2 Result:</h2><pre>' . print_r($result, true) . '</pre>';
if ($client->getAccessToken()) {
$_SESSION['token'] = $client->getAccessToken();
}
GET https://www.googleapis.com/analytics/v3/data/ga ?ids=ga:12345 &start-date=2008-10-01 &end-date=2008-10-31 &metrics=ga:visits,ga:bouncesAny ideas.
Ids is gotten from profile_id in google analytics