0
Google Cloud StorageとGoogle Playのレポートを使用しているときに問題があります。私はPHPで私のサーバー上のレポートを解析したいと思います。これを行うには、デフォルトのバケットのファイルを新しいバケットに移動したいと思います。私はそれをしようとすると、私は次のエラーを取得する:PlayストアレポートをGoogle Cloud Storageバケットにコピーする
Fatal error: Uncaught exception 'Google_Service_Exception' with message '{ "error": { "errors": [ { "domain": "global", "reason": "notFound", "message": "Not Found" } ], "code": 404, "message": "Not Found" } } ' in /var/www/d2/libs/googleAPI/src/Google/Http/REST.php:118 Stack trace: #0 /var/www/d2/libs/googleAPI/src/Google/Http/REST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #1 [internal function]: Google_Http_REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #2 /var/www/d2/libs/googleAPI/src/Google/Task/Runner.php(181): call_user_func_array(Array, Array) #3 /var/www/d2/libs/googleAPI/src/Google/Http/REST.php(58): Google_Task_Runner->run() #4 /var/www/d2/libs/googleAPI/src/Google/Client.php(781): Google_Http_REST::execute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...', Array) #5 /var/www/d2/libs/googleAPI/src/Google/Service in /var/www/d2/libs/googleAPI/src/Google/Http/REST.php on line 118
私はなぜ先のバケットが存在するため、元のファイルも知りません。
これは私のPHPスクリプトの私の実装です:
<?php
session_start();
require_once dirname(__FILE__).'/../libs/googleAPI/vendor/autoload.php';
$scopes = array("https://www.googleapis.com/auth/cloud-platform");
// Create client object
$client = new Google_Client();
$client->setRedirectUri('http://CENSORED/TEST_API.php');
$client->setAuthConfig("client_credentials_OAUTH.json");
$client->addScope($scopes);
if (isset($_SESSION['access_token']) && $_SESSION['access_token'])
{
$client->setAccessToken($_SESSION['access_token']);
$service = new Google_Service_Storage($client);
$request = $service->objects->listObjects("statsinstalls");
$objects = $request->getItems();
$sourceBucket = "pubsite_prod_rev_CENSORED";
$sourceObject = "installs_CENSORED_" . date("Ym") . "_app_version.csv";
$destinationBucket = "statsinstalls";
$destinationObject = $sourceObject;
$postBody = new Google_Service_Storage_StorageObject($client);
$response = $service->objects->copy($sourceBucket, $sourceObject, $destinationBucket, $destinationObject, $postBody);
foreach ($objects as $item)
echo $item->id . "<br>";
}
else if (!isset($_GET['code']))
{
$auth_url = $client->createAuthUrl();
header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
}
else
{
$client->authenticate($_GET['code']);
$_SESSION['access_token'] = $client->getAccessToken();
$redirect_uri = 'http://CENSORED/TEST_API.php';
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
私は404エラーを得たのはなぜ?おかげさまで