Jump to content

Cannot retrieve api.php results via cURL


turbofandude

Recommended Posts

Hello,

 

I posted this over on Stack Overflow and cannot seem to get an answer, and I'd appreciate any help someone could offer. The question was:

 

I am trying to use the WHMCS API to connect a third party script to it. I have created the third party's script as follows, however, when I try to connect to my site using HTTPS, I get this error: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

 

If I use HTTP, I get a 404 error. The code is as follows (and yes, that is my actual domain, since I figured the SSL's specifics might matter):

 

$email = $_GET["email"];
$password = $_GET["password"];
if(filter_var($email, FILTER_VALIDATE_EMAIL) && strlen($password) > 0) {
   $postfields["username"] = $apiusername;
   $postfields["password"] = $apipassword;
   $postfields["action"] = "validatelogin";
   $postfields["email"] = $email;
   $postfields["password2"] = $password;

   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, "https://tfdidesign.com/accounts/includes/api.php");
   curl_setopt($ch, CURLOPT_POST, 1);
   curl_setopt($ch, CURLOPT_TIMEOUT, 100);
   curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);   
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
   $data = curl_exec($ch);
   if(curl_error($ch))
       echo(curl_error($ch));
   curl_close($ch);     
   $data = explode(";",$data);
   foreach ($data AS $temp) {
       $temp = explode("=",$temp);
       $results[$temp[0]] = $temp[1];
   }
}
else
   die("INVALID_CREDENTIALS");

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated