我尝试使用自定义图片上传服务从Tweetbot上传图片,该服务使用在Github上找到的PHP脚本,该脚本使用在Imgur上注册第三方应用程序时给出的客户端ID,但似乎没有任何工作正常。每次上传失败。我究竟做错了什么?这是脚本:
<?php
/**
* Original script source
*
* http://playground.btolab.com/sandbox/qa/stackexchange/stackoverflow/17269448/index.php
* http://playground.btolab.com/sandbox/qa/stackexchange/stackoverflow/17269448/index.php.source
*/
$client_id = "MY_ID";
$image = $_POST['url'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.imgur.com/3/image.json');
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: Client-ID ' . $client_id ));
curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'image' => $image ));
$reply = curl_exec($ch);
curl_close($ch);
$reply = json_decode($reply);
$newimgurl = $reply->data->link;
echo $newimgurl;
exit();
?>