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 B2C Service

All supported versions

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 B2C Service.

In order to achieve this, the code needs to load the curl libraries available with Oracle B2C Service 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 the Online Help User Guide documentation. To access Oracle B2C Service manuals and documentation online, refer to the Documentation for Oracle B2C Service Products.