Level 88
Your URL is incorrect at the http:// part
// This
http:/localhost/project/public/api/api_jobpost
Should be this
http://localhost/project/public/api/api_jobpost
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi
I am getting empty curl response in laravel but when i tried in postman i am getting valid response. Here is my code
$ch = curl_init();
$url = "http:/localhost/project/public/api/api_jobpost";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
CURLOPT_HTTPHEADER => array(
"Authorization: ".$headers['authorization'],
"Cache-Control: no-cache",
"Content-Type: application/json",
$headers['date']
),
curl_setopt($ch, CURLOPT_POSTFIELDS, 'Job_pos_id=' . $job_pos_id . '&Job_loc=' . $job_loc . '&Job_type=' . $job_type . '&Job_title=' . $job_title . '&Datetimepicker1=' . $starts . '&Datepicker2=' .$end. '&start=' .$start. '&length=' .$limit);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$server_output = curl_exec($ch);
if (curl_error($ch)) {
$error_msg = curl_error($ch);
return Response::json(['msg' => 'Something Went Wrong'], 500);
}
curl_close($ch);
print_r($server_output);
exit();
Please or to participate in this conversation.