我想從存儲在谷歌雲存儲谷歌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