Quantcast
Viewing all articles
Browse latest Browse all 2504

Using CURL to call REST API (4 Comments)

Topic by Natraj Buddi

Hi ,

I am trying to call REST API from a sample PHP code as below.

<?php
{
load_curl();
$url = "https://userid:pwd.rightnowdemo.com/services/rest/connect/v1.3/accounts/25";
//send request to reource
$client = curl_init($url);
curl_setopt($client,CURLOPT_REURNTRANSFER,1);
//get response from Resource
$response = curl_exec($client);
echo $response;
//decode
$result = json_decode($response);
}
?>

But i am getting " Fatal error: Call to undefined function load_curl() in C:\xampp\htdocs\callrestapi.php on line 3"

If i removed load_curl() from the script getting following errors.

Notice: Use of undefined constant CURLOPT_REURNTRANSFER - assumed 'CURLOPT_REURNTRANSFER' in C:\xampp\htdocs\callrestapi.php on line 6

Warning: curl_setopt() expects parameter 2 to be long, string given in C:\xampp\htdocs\callrestapi.php on line 6.

I have checked in phpinfo() , CURL is enabled .

Please suggest ...

Thanks,

Natraj


Viewing all articles
Browse latest Browse all 2504

Trending Articles