imgur 通过 api 删除图片

问题描述 投票:0回答:3

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

$client_id = "xxxxxxxxxxxxxxxxx";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.imgur.com/3/image/pNAHgGq2WvXAUey');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Client-ID ' . $client_id));
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
var_dump($result);

如果我浏览图像网址,它仍然在那里。

php imgur
3个回答
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"
  },

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);

很难找到区别,如果有人可以请赐教。


-1
投票

我有同样的问题,但是使用 Laravel livewire,我无法从 imgur 服务器中删除图像

© www.soinside.com 2019 - 2024. All rights reserved.