PHP通过curl错误500发送POST请求

时间:2015-05-04 02:25:13

标签: php post curl

将POST请求发送到某个网站API

function httpPost($url,$params)
{


$ch = curl_init($url); 
$contents= json_encode($params);
$access_token='**************************';
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Token ' . $access_token,
  'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $contents);

$output=curl_exec($ch); 
curl_close($ch);
return $output;

}

$params = file_get_contents('./upload.json');
echo httpPost("https://xxxxx.com/api/v2/review/",$params);

但它无法将POST请求发送到服务器。

 Remote Address:[::1]:80
 Request URL:http://localhost/publons/submit.php
 Request Method:GET
 Status Code:500 Internal Server Error

为什么它使用GET,它应该是POST ????

1 个答案:

答案 0 :(得分:1)

添加此项以不验证SSL证书。如果它是一个开发服务器,那很好,如果它是生产,虽然这应该总是被验证。

Celluloid
相关问题