Skip to main content

cPanel API failure questions

Comments

1 comment

  • gunsuka
    Thought I would put an update here for the benefit of others. I am using the PHP XML API client class, verion 1.0.13. I found it has the following code: [PHP] // The only time a response should contain is in the case of authentication error // cPanel 11.25 fixes this issue, but if is in the response, we'll error out. if (stristr($response[0], '') == true) { if (stristr($response[0], 'Login Attempt Failed') == true) { error_log("Login Attempt Failed"); return; } if (stristr($response[0], 'action="/login/"') == true) { error_log("Authentication Error"); return; } return; } [/PHP] It was essentially assuming that if a reply every contained an tag that it was a failed login. I've found that if you try and connect to a cPanel server on port 2082 but it wants a secure connection on port 2083 that it will return a 301 Location: header, along with a meta refresh tag... and it contains the tag. I ended up making a couple of modifications to the API client class, to remove the above check and also rather than just returning the body that curl gets it will also return to me all headers returned by the remote server. So I have been able to increase my error handling by recognizing 301 Location redirects, 404 file not founds, 500 server class errors etc. Since I operate in not a very controlled environment (user's supply their cPanel URL's) we get all types of things sent to us that are not correct so having access to as much data like headers is very important for us.
    0

Please sign in to leave a comment.