PHP Curl to hastebin.com API不';行不通
我想使用hastebin.com的API向其提交一个新的粘贴,这是我在以下网站上偶然发现的: 我试过几种方法,但都没能成功。以下是我的简单代码:PHP Curl to hastebin.com API不';行不通,php,api,curl,Php,Api,Curl,我想使用hastebin.com的API向其提交一个新的粘贴,这是我在以下网站上偶然发现的: 我试过几种方法,但都没能成功。以下是我的简单代码: if(function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://hastebin.com/documents" ); curl_setopt($ch, C
if(function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://hastebin.com/documents" );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST, 1 );
//curl_setopt($ch, CURLOPT_POSTFIELDS, 'hello world');
//curl_setopt($ch, CURLOPT_POSTFIELDS, 'data=hello world');
curl_setopt($ch, CURLOPT_POSTFIELDS, array('data'=>'hello world'));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data'));
//curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
$response_json = curl_exec($ch);
curl_close($ch);
$response_array = json_decode($response_json,true);
print_r ($response_array);
} else {
error_log("You need cURL to use this api!");
}
如有任何建议,将不胜感激。提前感谢。Hastebin似乎正在将其http方案重定向到https。因此,您需要使用
https://hastebin.com/documents
其余的似乎都和以前一样。Hastebin似乎正在将他们的http方案重定向到https。因此,您需要使用
https://hastebin.com/documents
其余的似乎都和以前一样