I would like to fetch data from Google Play Analytics which is stored in Google Cloud Storage. After researching lot discovered that there is no direct API to get Google Play Analytics report data. Hence I found Access Google play account reports through Google API Client PHP Library link and followed the same given. I have created service account, given owner permission, and enabled google cloud api too.
In the code shown in the link i am getting junk data if i var_dump($bucket) , and if run the further code , i get this error.
Fatal error: Uncaught exception 'Google\Cloud\Exception\ServiceException' with message '{ "error": { "errors": [ { "domain": "global", "reason": "forbidden", "message": "Caller does not have storage.objects.list access to bucket I cannot show any JS fiddle as the bucket name and other information like key is confidential to company. Here is code i used,
require 'vendor/autoload.php';
use Google\Cloud\Storage\StorageClient;
$client = new StorageClient([ 'projectId'=> 'myproject-id','scopes'=> [StorageClient::READ_ONLY_SCOPE],'keyFile'=> json_decode(file_get_contents('path_to_jsonfile'), true) ]); $bucket=$client->bucket('mybucketname');
/*Find bucket name in Google Developer Console>>Reports */
$buckets=$client->buckets([ 'prefix' => 'stats/installs/']);
foreach ($buckets as $bucket) {echo $bucket->name().PHP_EOL; }
Accepting some help. Please tell me some solution. Thanks in advance
stats/installs/
prefix? – Nicholas