我计划使用其api匿名上传图像到imgur,我在匿名上传类别中注册了我的应用程序,并获得客户端ID和客户端密码,如何使用php将图像上传到imgur并将图像直接检索到图像?
任何人都可以建议任何示例的链接?
这是我试图做的,但我得到错误“致命错误:最大执行时间超过30秒”
$client_id = :client_id; //put your api key here
$filename = "images/q401x74ua3402.jpg";
$handle = fopen($filename, "r");
$data = fread($handle, filesize($filename));
//$data is file data
$pvars = array('image' => base64_encode($data), 'key' => $client_id);
$timeout = 30;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.imgur.com/3/upload.json');
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $pvars);
$xml = curl_exec($curl);
$xmlsimple = new SimpleXMLElement($xml);
echo '';
curl_close ($curl);
?>