Shah
Shah

Reputation: 505

CURL Usage in making Api Call

Can someone suggest me to make curl api call for these syntax

curl -u [email protected]:c14b85863755158d7aa5cc4ba17f61cb -H X-API-Version:2 https://api.livechatinc.com/agents

I tried to use this code but not succeed

$url = [email protected]:c14b85863755158d7aa5cc4ba17f61cb@https://api.livechatinc.com/offline_messages";
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_exec($ch);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$results = curl_exec($ch);
curl_close($ch);
echo '<pre>';print_r($results);

Upvotes: 0

Views: 224

Answers (1)

Venkata Krishna
Venkata Krishna

Reputation: 4305

You can find curl library for CodeIgniter framework here from the developer site itself. Load the library in your controller like below.

$this->load->spark('curl');

and make a simple call to your api using curl simple_get method like below and save the response in a variable. Use it based on how you are getting either JSON/XML.

$this->curl->simple_get('http://example.com/');

For reference please visit this link.

Upvotes: 1

Related Questions