我们如何使用JSON API和php curl删除谷歌云存储对象。
答案 0 :(得分:1)
$obejct = rawurlencode ($obejct); // $object : object name
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.googleapis.com/storage/v1/b/".BUCKET."/o/".$obejct);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$headers = array();
$headers[] = "Authorization: Bearer ".$token;
$headers[] = "Content-Type: application/http";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
echo $result