Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2004
    Posts
    104
    Thanks
    7
    Thanked 2 Times in 2 Posts

    HTTPS connections

    Hi Guys
    This is probably a simple error, its just i've never dealt with these before and google didn't seem to give me any luck.

    I'm installing a script and step 2 says:
    After a successful authentication, it redirects the user back to the token_url at your website as specified in step 1. Write some code to handle requests to your token_url, and extract the token parameter.

    Make the auth_info API call

    HTTP POST to https://url.com (url edited) with the following required parameters:
    apiKey Key Removed
    token Use the token sent to your token_url
    How can I post the data to the url and get the response that's produced? I can't really see where to go with this. A fopen() produced a "400 BAD REQUEST" response, and other than that I don't really know where to go, so any help would be highly appreciated.

    Cheers
    Matt

  • #2
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You may want to make sure allow_url_fopen is enabled in your PHP configuration.

    http://us2.php.net/manual/en/filesys...llow-url-fopen

  • #3
    Regular Coder
    Join Date
    Oct 2004
    Posts
    104
    Thanks
    7
    Thanked 2 Times in 2 Posts
    Thanks for that response. It seems to open external pages at the moment, so I've sieved through existing code and got a little bit further, but still not all the way. Just as a sample, I've included my request, the php code and the servers response. Any help would be brilliant. thanks

    PHP Code:
    $token $_GET['token'];

        
    $fp fsockopen("rpxnow.com"443$errno$errstr5);
        if (!
    $fp) {
            echo 
    "$errstr ($errno)<br />\n";
        } else {
            
    $out "POST ssl://rpxnow.com/api/v2/auth_info?apiKey=REMOVED&token=".$token."&format=xml HTTP/1.0\r\n";
            
    $out .= "Host: rpxnow.com\r\n";
            
    $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
            
    $out .= "Content-Length: 0\r\n";
            
    $out .= "Connection: Close\r\n\r\n";
            echo 
    no_html($out).'<br/><br/>';
            
    fwrite($fp$out);
            while (!
    feof($fp)) {
                
    $data fgets($fp128);
                
    $data no_html($data);
                echo 
    $data;
            }
            
    fclose($fp);
        }

    function 
    no_html($s) {
        
    $s str_replace("<""&lt;"$s);
        
    $s str_replace(">""&gt;"$s);
        
    $s str_replace("\r\n""<br/>"$s);
        return(
    $s);



    Have also tried http:// and https:// as well as ssl:// after POST:
    Quote Originally Posted by My Request
    POST https://rpxnow.com/api/v2/auth_info?...VED&format=xml HTTP/1.0
    Host: rpxnow.com
    Content-Type: text/html
    Content-Length: 0
    Connection: Close


    Quote Originally Posted by Server Response
    HTTP/1.1 400 Bad Request
    Server: nginx/0.6.32
    Date: Fri, 20 Mar 2009 23:19:58 GMT
    Content-Type: text/html
    Content-Length: 271
    Connection: close

    <html>
    <head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
    <body bgcolor="white">
    <center><h1>400 Bad Request</h1></center>
    <center>The plain HTTP request was sent to HTTPS port</center>
    <hr><center>nginx/0.6.32</center>
    </body>
    </html>
    Just to let you know, when trying to send to a port 80, I get this:
    Quote Originally Posted by Server Response on port 80
    HTTP/1.1 301 Moved Permanently
    Server: nginx/0.6.32
    Date: Fri, 20 Mar 2009 23:48:01 GMT
    Content-Type: text/html
    Content-Length: 185
    Connection: close
    Location: https://rpxnow.com/api/v2/auth_info?...VED&format=xml

    <html>
    <head><title>301 Moved Permanently</title></head>
    <body bgcolor="white">
    <center><h1>301 Moved Permanently</h1></center>
    <hr><center>nginx/0.6.32</center>
    </body>
    </html>
    Thanks once again!
    And, as a side note, I'm not a good coder


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •