Curl not working in homestead

Posted 1 year ago by eddieace

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]
            $info = curl_getinfo($ch);

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.