Sep 26, 2017
0
Level 11
Curl not working in homestead
For some reason, I can't use CURL to send post requests in homestead. It just returns null and here is my code.
Additional, headers are not being set, even if it's application/json it returns HTML/charset.
any clues?
$ch = curl_init(env('app_url') . 'applications/' . $position->ats_reference . '/import');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'token' => $user->token,
'data' => [$data]
]));
curl_exec($ch);
$info = curl_getinfo($ch);
dd($info);
curl_close($ch);
Please or to participate in this conversation.