i have written code for Post request to REST API
, but it's sending GET
request. I'm printing request method at the end of the code. Please help me to solve this issue. and i'm working in localhost to get the response. And the
$credentials = "xxxx:yyyy";
$url = "http://api.utrust.in/get/token";
$page = "/get/token";
$headers=[
'POST ".$page." HTTP/1.1',
'Content-Type: application/x-www-form-urlencoded',
'Content-Length:0',
'Authorization: Basic ' . base64_encode($credentials),
'Connection:keep-Alive',
'Host:api.utrust.in',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, CURLOPT_POSTFIELDS, array());
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
$data = curl_exec($ch);
curl_close($ch);
echo $data;
print_r(get_headers($url));
$CurrentURL1="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].$_SERVER['REQUEST_METHOD'].$_SERVER["REMOTE_ADDR"];;
echo $CurrentURL1;