I have python api url which is a get request. It gives response in below format:
{"Status":"DONE"}
I am using curl
in php to call the api and get the above url but nothing is getting displayed. Below is the code:
<form action="test.php" method="post" enctype="multipart/form-data">
<input type="submit" name="testapi" value="Test API " />
</form>
<?php
if(isset($_POST['testapi']))
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://<api_url>/api/v1/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
echo $data;
}
?>
Please help. Thanks
Below is the response after adding var_dump(curl_getinfo($ch));
G:\wamp\www\test.php:37:
array (size=26)
'url' => string 'https://<api_url>/api/v1/' (length=41)
'content_type' => null
'http_code' => int 0
'header_size' => int 0
'request_size' => int 0
'filetime' => int -1
'ssl_verify_result' => int 20
'redirect_count' => int 0
'total_time' => float 0.596189
'namelookup_time' => float 0.047973
'connect_time' => float 0.338623
'pretransfer_time' => float 0
'size_upload' => float 0
'size_download' => float 0
'speed_download' => float 0
'speed_upload' => float 0
'download_content_length' => float -1
'upload_content_length' => float -1
'starttransfer_time' => float 0
'redirect_time' => float 0
'redirect_url' => string '' (length=0)
'primary_ip' => string '52.173.77.140' (length=13)
'certinfo' =>
array (size=0)
empty
'primary_port' => int 443
'local_ip' => string '192.168.0.102' (length=13)
'local_port' => int 52566