Send the POST request to some website 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);
but it can't send the POST request to the server.
Remote Address:[::1]:80
Request URL:http://localhost/publons/submit.php
Request Method:GET
Status Code:500 Internal Server Error
Why it use the GET, it should be POST ????