imgur通过api删除图像

时间:2018-07-29 11:07:51

标签: php imgur

我尝试使用图像ID而不是deletehash从api中删除图像,因为当我上传图像时,它没有给我deletehash。 这是我尝试过的。

1

如果我浏览图片网址,它仍然存在。

2 个答案:

答案 0 :(得分:0)

https://apidocs.imgur.com不允许您通过ID删除图片。

上传图像时,您应该拥有deletehash。使用它代替id。

data": {
    "id": "orunSTu",
    "title": null,
    "description": null,
    "datetime": 1495556889,
    "type": "image/gif",
    "animated": false,
    "width": 1,
    "height": 1,
    "size": 42,
    "views": 0,
    "bandwidth": 0,
    "vote": null,
    "favorite": false,
    "nsfw": null,
    "section": null,
    "account_url": null,
    "account_id": 0,
    "is_ad": false,
    "in_most_viral": false,
    "tags": [],
    "ad_type": 0,
    "ad_url": "",
    "in_gallery": false,
    "deletehash": "x70po4w7BVvSUzZ",
    "name": "",
    "link": "http://i.imgur.com/orunSTu.gif"
  },

答案 1 :(得分:0)

Ok guys following code worked,

$client_id = "xxxxxxxxxxxxxxxx";
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api.imgur.com/3/image/"."lm1sOhLidoThyoW");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");


$headers = array();
$headers[] = "Authorization: Client-ID ".$client_id;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
var_dump($result);

很难找到区别,如果有人可以请给我们启发。