Skip Navigation
Expand
Use of load_curl() function in multiple scripts
Answer ID 10789   |   Last Review Date 05/18/2020

Why is my load_curl() function failing when being used concurrently in several scripts?

Environment

Oracle Service Cloud - all supported releases

Resolution

As described in the general Connect PHP API documentation, curl can be used to enable external integrations using the Custom Processes functionality available with Oracle Service Cloud.

In order to achieve this, the code needs to load the curl libraries available with Oracle Service Cloud starting with August 2013 release, by making use of the sample code below:

==============================

load_curl();
$curl = curl_init();

static::$url_used = $url;

curl_setopt_array($curl,array(
CURLOPT_URL => $url,
CURLOPT_HEADER => 0,
CURLOPT_HTTPHEADER => $header,
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_CONNECTTIMEOUT => 20,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_SSL_VERIFYHOST => 0
));
$content = curl_exec($curl);

==============================

When the curl libraries are used/called concurrently in multiple scripts, we need to ensure that the following check is performed before loading the libraries, to prevent any code failures:

if(!extension_loaded('curl')) { load_curl(); }


For additional information, refer to the Custom Process Overview section in online documentation for the version your site is currently running. To access Oracle Service Cloud manuals and documentation online, refer to the Documentation for Oracle Service Cloud Products.

Available Languages for this Answer:

Notify Me
The page will refresh upon submission. Any pending input will be lost.