You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Using CURL to call REST API

Accepted answer
29
Views
11
Comments
edited Oct 25, 2016 10:26AM in Integrations and APIs 11 comments

Content

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

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!