我想从存储在谷歌云存储谷歌Play分析数据。经过调查发现,Google Play Analytics报告数据没有直接API。 因此,我发现Access Google play account reports through Google API Client PHP Library链接,并遵循相同的给定。我已经创建了服务帐户,获得了所有者的许可,并启用了Google云API。如何解决403被禁止访问存储桶谷歌云存储
在链接中显示的代码中,我收到垃圾数据,如果我var_dump($桶),并且如果运行进一步的代码,我得到这个错误。
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; }
接受一些帮助。请告诉我一些解决方案。在此先感谢
我想你应该检查你的代码的第153行。我们无法帮助您查看您的代码。 – DaImTo
根据[试图访问云存储的设备](https://cloud.google.com/docs/authentication#getting_credentials_for_server-centric_flow),身份验证要求可能会有所不同。这段代码在哪里运行?是否所有的存储桶名称都以['stats/installs /'前缀]开头(https://googlecloudplatform.github.io/google-cloud-php/#/docs/google-cloud/v0.24.0/storage/storageclient?方法=桶)? – Nicholas