Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

eddieace's avatar

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);
0 likes
0 replies

Please or to participate in this conversation.