我正在使用Imgur从我的网站上传照片。
这是我的密码
$client_id = '*********';
$image = file_get_contents($_FILES['update_profile_photo']['tmp_name']);
$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' => base64_encode($image)));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$reply = curl_exec($ch);
curl_close($ch);
$reply = json_decode($reply);
echo "<h3>Image</h3>";
printf('<img height="180" src="%s" >', $reply->data->link);
echo "<h3>API Debug</h3><pre>";
var_dump($reply);当我第一次上传一个文件时,它打印出了图像。但是从下一次尝试开始,我无法查看文件,而在laravel中,我得到了这样一个错误

当清除printf('<img height="180" src="%s" >', $reply->data->link);以检查var_dump()的结果时,它会给我这样的结果
object(stdClass)#219 (3) {
["data"]=>
object(stdClass)#215 (3) {
["error"]=>
object(stdClass)#212 (4) {
["code"]=>
int(1016)
["message"]=>
string(27) "Banned country attempt (IN)"
["type"]=>
string(16) "Exception_Logged"
["exception"]=>
array(0) {
}
}
["request"]=>
string(13) "/3/image.json"
["method"]=>
string(4) "POST"
}
["success"]=>
bool(false)
["status"]=>
int(400)
}我住在印度(它告诉我们,禁止国家企图)
我想知道如何修正这个错误?为什么它第一次起作用,而现在却不起作用。
我在本地,还没有主持。
这是我的代码问题吗?
,请告诉我如何修复这个
发布于 2017-04-30 14:08:23
Imgur在印度被阻塞,所以您无法访问API。
解决这个问题的唯一可靠方法是通过代理访问API。
来源:http://thehackernews.com/2015/01/indian-government-blocks-32-sites.html
https://stackoverflow.com/questions/43707239
复制相似问题