0
我想使用它的API,這是我偶然發現在提交新貼到hastebin.com:https://github.com/seejohnrun/haste-server/wiki/POST-apiPHP捲曲hastebin.com API不起作用
我試過多種方法,但couldn不要讓它工作。這是我的簡單代碼:
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!");
}
任何意見將非常感激。提前致謝。