I tried google-api-php-client
<?php
require_once 'google-api-php-client-2.2.2\vendor\autoload.php';
putenv('GOOGLE_APPLICATION_CREDENTIALS=client_secret.json');
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->addScope(Google_Service_AndroidPublisher::ANDROIDPUBLISHER);
$android_publisher = new Google_Service_AndroidPublisher($client);
$response = $android_publisher->reviews->listReviews('appname');
echo "<pre>";
var_dump($response);
And help me with this
$android_publisher = new Google_Service_AndroidPublisher($client);
$response = $android_publisher->reviews->listReviews('appname');
am I doing it right?
please give me some resources to write a google api call using php. I am trying to get the all reviews for my app in playstore.
I am trying make this call in php. Google documentation
Result I Got from running the code above
object(Google_Service_AndroidPublisher_ReviewsListResponse)#70 (10) {
["collection_key":protected]=>
string(7) "reviews"
["pageInfoType":protected]=>
string(40) "Google_Service_AndroidPublisher_PageInfo"
["pageInfoDataType":protected]=>
string(0) ""
["reviewsType":protected]=>
string(38) "Google_Service_AndroidPublisher_Review"
["reviewsDataType":protected]=>
string(5) "array"
["tokenPaginationType":protected]=>
string(47) "Google_Service_AndroidPublisher_TokenPagination"
["tokenPaginationDataType":protected]=>
string(0) ""
["internal_gapi_mappings":protected]=>
array(0) {
}
["modelData":protected]=>
array(0) {
}
["processed":protected]=>
array(0) {
}
}
when I did
var_dump($client);
Config I got is
["config":"Google_Client":private]=>
array(23) {
["application_name"]=>
string(9) "php_level"
["base_path"]=>
string(26) "https://www.googleapis.com"
["client_id"]=>
string(0) ""
["client_secret"]=>
string(0) ""
["redirect_uri"]=>
NULL
["state"]=>
NULL
["developer_key"]=>
string(0) ""
["use_application_default_credentials"]=>
bool(true)
["signing_key"]=>
NULL
["signing_algorithm"]=>
NULL
["subject"]=>
NULL
["hd"]=>
string(0) ""
["prompt"]=>
string(0) ""
["openid.realm"]=>
string(0) ""
["include_granted_scopes"]=>
NULL
["login_hint"]=>
string(0) ""
["request_visible_actions"]=>
string(0) ""
["access_type"]=>
string(6) "online"
["approval_prompt"]=>
string(4) "auto"
["retry"]=>
array(0) {
}
["cache_config"]=>
array(0) {
}
["token_callback"]=>
NULL
["jwt"]=>
NULL
}
Is this normal?
When you want to access a google api. You need to create an application on Google Developer console. Once your application is set up you will get a credentials file. This file is used in your code to access a Google api. It tells google and the user who will be logging in who the owner of the application is and what data they will be requesting.
You can see this in the following picture. The application google analytics windows would like to request access of the user for Google analytics data.
The credentials file does not give you access to a users data. The user who logs into the application and grants access will be the one who grants the access to the data.
You may have been given a credentials file but you must also be given a login and password to a google account that has access to the data or your not going to be able to see anything.
TBH i am surprised you are not getting an error message. In the off chance that you are using a service account which i cant see from your code. You need to make sure that its set up properly to have access to the data or you will also not be able to see it.