我可以使用google-api-php-client將文件(image.png)放到我的Google Cloud Storage存儲桶中,但現在我無法嘗試創建簽名url從我的網站訪問該文件。示例代碼:Google Cloud Storage簽署的Url - SignatureDoesNotMatch
$bucketName = 'bucket-name';
$id = 'image.png';
$serviceAccountName = '[email protected]';
$privateKey = file_get_contents($location_to_key_file);
$signer = new \Google_P12Signer($privateKey, "notasecret");
$ttl = time() + 3600;
$stringToSign = "GET\n" . "\n" . "\n" . $ttl . "\n". '/' . $bucketName . '/' . $id;
$signature = $signer->sign(utf8_encode($stringToSign));
$finalSignature = \Google_Utils::urlSafeB64Encode($signature);
$host = "https://".$bucketName.".storage.googleapis.com";
echo $host. "/".$id."?GoogleAccessId=" . $serviceAccountName . "&Expires=" . $ttl . "&Signature=" . $finalSignature;
返回:使用谷歌的API的PHP客戶端使用PHP
<Error><Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.</Message>
<StringToSign>
GET 1387590477 /bucketname/image.png</StringToSign></Error>
IM 5.5
香港專業教育學院遵循的幾個例子:
https://groups.google.com/forum/#!topic/gs-discussion/EjPRAWbWKbw
https://groups.google.com/forum/#!msg/google-api-php-client/jaRYDWdpteQ/xbNTLfDhUggJ
也許一個配置值我沒有正確傳遞? 我假設使用服務帳戶電子郵件。還嘗試在$ stringToSign中包含md5hash和content-type,結果相同。
任何幫助/提示,將不勝感激。
相同的結果,改變子域 – rdb