Pelsedu

Registered
Aug 20, 2016
4
0
1
Poland
cPanel Access Level
Root Administrator
I have problem with this code, it works, but website is locked, and don't return any information, then it's reloaded, and return that account exists, i can't handle this problem, other api calls works fine.

Code:
require __DIR__ . '/config.php';

$data = [
'username' => 'samplexxx',
'domain'   => 'samplexxx.samplexxx.samplexxx',
'password' => 'samplexxx'
];

$query = 'https://samplexxx.samplexxx.net:2087/json-api/createacct?api.version=1';

foreach ( $data as $k => $v ) {
$query .= '&' . $k . '=' . $v;
}

$whmusername = 'root';

$hash = $access_key;

$curl = curl_init();
curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );

$header[ 0 ] = "Authorization: WHM $whmusername:" . preg_replace( "'(\r|\n)'", '', $hash );
curl_setopt( $curl, CURLOPT_HTTPHEADER, $header );
curl_setopt( $curl, CURLOPT_URL, $query );

$result = curl_exec( $curl );
if ( $result == false ) {
error_log( "curl_exec threw error \"" . curl_error( $curl ) . "\" for $query" );
}
curl_close( $curl );

print $result;
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,222
463
I have problem with this code, it works, but website is locked, and don't return any information, then it's reloaded, and return that account exists, i can't handle this problem, other api calls works fine.
Hello,

Could you provide some additional details, including full error messages, on the steps you are taking to reproduce this issue? Can you reproduce the problem when using the command line example on the WHM API 1 Functions - createacct document?

Thank you.
 

Pelsedu

Registered
Aug 20, 2016
4
0
1
Poland
cPanel Access Level
Root Administrator
I add file from console log, same info i can receive from php, but only with saving output to file, but server doesn't response anything, i got this response from browser, with other calls, i got very fast response, and can see result on browser.

The {domain} page isn’t working
{domain} didn’t send any data.

ERR_EMPTY_RESPONSE
 

Attachments

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,222
463
but server doesn't response anything, i got this response from browser, with other calls, i got very fast response, and can see result on browser.

The {domain} page isn’t working
{domain} didn’t send any data.

ERR_EMPTY_RESPONSE
I'm not sure I understand the issue. Could you let us know the step-by-step instructions we can take to reproduce this problem?

Thank you.
 

Pelsedu

Registered
Aug 20, 2016
4
0
1
Poland
cPanel Access Level
Root Administrator
I want to use function echo, or print, to display information API sent back, but server doesn't respond. I got only error from browser "ERR_EMPTY_RESPONSE". It's like creating cPanel account disables server PHP output to WWW server (Apache). I can save response to file, but i can't send response to browser. I need to let know user that created the account that account is created, he needs to get that information.
 

Pelsedu

Registered
Aug 20, 2016
4
0
1
Poland
cPanel Access Level
Root Administrator
I looked over in the logs for information about this problem, but i found nothing. I think problem may be caused by function new profile - during that, as i know, the apache is restarted (right?), so PHP script will stop, i may be wrong, but i can't find solution...
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,222
463
Feel free to open a support ticket using the link in my signature so we can take a closer look. You can post the ticket number here so we can update this thread with the outcome.

Thank you.