How to apply cUrl get data in CodeIgniter How to apply cUrl get data in CodeIgniter curl curl

How to apply cUrl get data in CodeIgniter


In the controller would be fine, for example

`function index(){    // Get cURL resource    $curl = curl_init();    // Set some options - we are passing in a useragent too here    curl_setopt_array($curl, array(        CURLOPT_RETURNTRANSFER => 1,        CURLOPT_URL => 'http://localhost/ci_paginationv2-        master/index.php/API/API_airtime_share',        CURLOPT_USERAGENT => 'Codular Sample cURL Request'    ));    // Send the request & save response to $resp    $resp = curl_exec($curl);    // Close request to clear up some resources    curl_close($curl);    echo $resp;}` 


Best practice would be putting your logic in the controller itself as per the Code Igniter Conventions and then process the response there itself (if needed) and then render the view for the same (if the data needs to be viewed). Please comment if something is unclear.

Click Here to see more on this