Hi there,
I wrote a piece of code which will allow me to connect through the cpanel xml-api to do certain actions ie: create account.
I am using curl for the connection and perform actions on SERVER A.
Running the script on my locahost(xampp) (connecting and creating on SERVER A). works perfectly.
Running the script on SERVER A (connecting and creating on SERVER A) i notice that i cannot get any response from the server and my code breaks.
Running the script on SERVER B (connecting and creating on SERVER A) it works perfectly.
My code is found below:
$url="https://thesite.com:2087/something";
$data = "somedat=xyz&soemthing=xsd";
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
// Return contents of transfer on curl_exec
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// Allow self-signed certs
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
// Set the URL
curl_setopt($curl, CURLOPT_URL, $url);
// Increase buffer size to avoid "funny output" exception
curl_setopt($curl, CURLOPT_BUFFERSIZE, 131072);
// Pass authentication header
/* */
/* */
$header[0] ="Authorization: Basic base64_encode(user:pass)"."
".
"Content-Type: application/x-www-form-urlencoded
" .
"Content-Length: " . strlen($data) . "
" . "
" . $data;
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 0);
$result = curl_exec($curl);
curl_close($curl);
Thanks for any help,
It has been 4 days and i am having headaches :sen: and really need a solution as it is core of the system.
Regards,
Jerome