0
Я хотел бы представить новую пасту hastebin.com, используя его API, который я наткнулся на: https://github.com/seejohnrun/haste-server/wiki/POST-apiPHP Curl для hastebin.com API не работает
Я попытался несколько способов, но не мог «Не заставляй его работать. Вот мой простой код:
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!");
}
Любой совет будет очень признателен. Заранее спасибо.