I am making an API request using cURL but I'm getting a blank result. I tried to var_dump
the url then tried the url on the browser and works fine. Here's my code.
$parameters = array(
"user" => urlencode('xxxx'),
"password" => urlencode('xxxx'),
"msisdn" => urlencode('09277878067'),
"type" => urlencode('full'),
);
$post_data = '';
//create name value pairs seperated by &
foreach($parameters as $k => $v)
{
$post_data .= $k . '='.$v.'&';
}
// Remove the & from the last
$post_data2 = rtrim($post_data, '&');
$url = "http://www.telcoportal.com/hlr/check?";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url.$post_data2);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER, false);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$output=curl_exec($ch);
curl_close($ch);
var_dump($output);
var_dump($url.$post_data2);
exit();
The $url.$post_data2
is http://www.telcoportal.com/hlr/check?user=xxxx&password=xxxx&msisdn=09277878032&type=full
which when you checked the browser gives a response {"status":"error","remark":"Authentication Failed"}
. But my $output
is blank and not getting anything.