I have access_token
and now to try get fata from Google API using this sample:
https://developers.google.com/android-publisher/api-ref/edits/details/get
I try to get data executing query to this URL:
https://www.googleapis.com/androidpublisher/v2/applications/packageName/edits/editId
$curl = new Curl();
$curl->get('https://www.googleapis.com/androidpublisher/v1/applications/com.shazam.android&access_token='.$_SESSION['access_token']["access_token"]);
Where $_SESSION['access_token']["access_token"]
is access_token
As a result I get message: Error: 404: HTTP/1.1 404 Not Found
How to get information from API?
This is full URL request, it does not work:
https://www.googleapis.com/androidpublisher/v2/applications/com.shazam.android/edits/1?access_token=ya29.Ci-5Azg5JoBiESM5cEzM3TQrP3SXHAFirFg0f-Fj83PxtrtINWQDe2L-3f5wP7oAtQ
{
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}
Full code is:
// Create the client object and set the authorization configuration
// from the client_secretes.json you downloaded from the developer console.
$client = new Google_Client();
$client->setAuthConfig(__DIR__ . '/client_secrets.json');
$client->addScope(Google_Service_Analytics::ANALYTICS_READONLY);
// If the user has already authorized this app then get an access token
// else redirect to ask the user to authorize access to Google Analytics.
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
// Set the access token on the client.
$client->setAccessToken($_SESSION['access_token']);
$curl = new Curl();
$curl->get('https://www.googleapis.com/androidpublisher/v1/applications/com.shazam.android/edits/1/&access_token='.$_SESSION['access_token']["access_token"]);
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n";
} else {
echo 'Response:' . "\n";
var_dump($curl->response);
}
// Create an authorized analytics service object.
//$analytics = new Google_Service_Analytics($client);
// Get the first view (profile) id for the authorized user.
//$profile = getFirstProfileId($analytics);
// Get the results from the Core Reporting API and print the results.
//$results = getResults($analytics, $profile);
//printResults($results);
} else {
$redirect_uri = 'http://localhost/play/oauth2callback.php';
header('Location: ' . $redirect_uri);
}
After getting access_token
I try to make Curl request:
$curl = new Curl();
$curl->get('https://www.googleapis.com/androidpublisher/v1/applications/com.shazam.android/edits/1/&access_token='.$_SESSION['access_token']["access_token"]);