Object 使用JSON API删除Google云存储桶对象

Object 使用JSON API删除Google云存储桶对象,object,curl,google-cloud-storage,bucket,php-curl,Object,Curl,Google Cloud Storage,Bucket,Php Curl,如何使用JSON API和php curl删除google云存储对象 $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

如何使用JSON API和php curl删除google云存储对象

    $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