// init cURL handle
$curlHandle = curl_init();
$cookieHeader = '';
// previously extracted cookies in $cookieArr (above), is used to add the
// session token in HTTP request header for subsequent REST call
foreach ($cookieArr as $key=>$value) {
$cookieHeader .= "$key=$value; ";
}
if (!empty($cookieHeader)) {
curl_setopt($curlHandle, CURLOPT_COOKIE, $cookieHeader);
}
// set other relevant HTTP option as shows in above section _Setting up the HTTP Options_
$headerArr = array('Accept: ' . $this->acceptType, 'Expect: 100-continue');
$requestBody = array('Filename'=>'@'.$fileName);
curl_setopt($this->curlHandle, CURLOPT_POST, true);
curl_setopt($this->curlHandle, CURLOPT_HTTPHEADER, $headerArr);
curl_setopt($this->curlHandle, CURLOPT_POSTFIELDS, $requestBody);
// Sonus SBC 1000/2000 REST system resource URL
$systemResource = "https://ux_host_or_ipaddress/rest/system?action=importconfig";
// set the system resource url in curl
curl_setopt($curlHandle, CURLOPT_URL, $systemResource );
// exec the HTTP/REST request
$response = curl_exec($curlHandle);
|