Fork me on GitHub


This class is for calling a HTTP API using Curl. It provides 1 public method and has 2 public properties.



Executes Curl call:

$status = Curl::call('GET','',array('q'=>$query),$result);

Note that the $data parameter can either be an array (normally) or a string (for raw POST). In the view (.phtml) file we can show the return status (200 for success):

<?php e($status); ?>


Curl::$options = array();

This array hold the Curl options for the next call as defined in the PHP manual. This example shows how to enable response headers to be included in the response:

Curl::$options['CURLOPT_HEADER'] = true;


Curl::$headers = array();

This array hold the HTTP request headers that Curl will send in the next call. This example shows how to set the content type of the POST data for the next request:

Curl::$headers['Content-Type'] = 'application/json';
close08:42:29 - get /docs/curl - 1 ms - 1 MB - debugger