How to pass form data to API or External URL through controller in Codeigniter

Viewed 75

I want to send the form data(input fields) to external URL from controller, but at end point of URL data is not submitted. So, how can I pass data? pls anyone help me.... This is code am trying

$send_que = Checksum::outputForm($checksum)// $checksum contain all input fields.
$curl = curl_init('myUrl here');

        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");

        curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Content-Length: ' . strlen($send_que)
        )
        );

        curl_setopt($curl, CURLOPT_VERBOSE, true);

        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);  // Make it so the data coming back is put into a string
        curl_setopt($curl, CURLOPT_POSTFIELDS, $send_que);  // Insert the data

        // Send the request
        $result = curl_exec($curl);

        // Free up the resources $curl is using
        curl_close($curl);

        echo $result;
0 Answers
Related