PHP + CURL HTTPS Connection Error

Discussion in 'PHP' started by afimafis, Feb 2, 2012.

  1. #1
    Hello Gurus,

    whenever i tried codes below on my localhost machine, i get error "ssl_error_rx_record_too_long".
    i will be very appreciateed if u help me.

    thanks

    <?php

    $url = 'https://twitter.com/sessions?phx=1';
    $login_email="xxxx"; //your email for twitter
    $login_password="yyyy"; //your password
    $post = "session[username_or_email]=".$login_email."&session[password]=".$login_password."&commit=Sign In";
    $cookie="cookie.txt"; //this is the file where store the cookie

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
    curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
    curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
    curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);
    curl_setopt ($ch, CURLOPT_POST, 1);
    $data = curl_exec ($ch);
    curl_close($ch);

    echo $data;

    ?>
     
    afimafis, Feb 2, 2012 IP
  2. RamMurti

    RamMurti Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This error means there is some problem in SSL implementation on your server.Please check whether port 443 is opened or not.
     
    RamMurti, Feb 2, 2012 IP
  3. afimafis

    afimafis Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    thanks RamMurti :)

    i try this code on hostgator.

    i guess there is redirect problem.here is another error i got

    HTTP/1.1 200 OK Date: Sat, 04 Feb 2012 17:27:12 GMT Status: 200 OK X-Transaction: c59d391ed14ff734 ETag: "ecd433e9a5ee151b38c338868851299e" X-Frame-Options: SAMEORIGIN Last-Modified: Sat, 04 Feb 2012 17:27:12 GMT X-Runtime: 0.18429 Content-Type: text/html; charset=utf-8 Content-Length: 61136 Pragma: no-cache X-Revision: DEV Expires: Tue, 31 Mar 1981 05:00:00 GMT Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0 X-MID: abaa631e94ad6060b35aa08a4a532c72917a05b2 Set-Cookie: k=10.35.42.138.1328376432546266; path=/; expires=Sat, 11-Feb-12 17:27:12 GMT; domain=.twitter.com Set-Cookie: guest_id=v1%3A132837643255268625; domain=.twitter.com; path=/; expires=Tue, 04-Feb-2014 05:27:12 GMT Set-Cookie: original_referer=wCS7VBxm%2BGD0zMKTVY5iCRhWOMBxJYV1; path=/ Set-Cookie: external_referer=wCS7VBxm%2BGD0zMKTVY5iCRhWOMBxJYV1%7C0; path=/; expires=Sun, 05-Feb-2012 17:27:12 GMT Set-Cookie: _twitter_sess=BAh7CToPY3JlYXRlZF9hdGwrCLfHZ0k1AToHaWQiJWJmMzY0NTg5MTZiODg4%250AZGUyYzdmMTdhOGU1ZTk1MjA2IgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsAOgxjc3JmX2lkIiUzNmRj%250ANDkzNGQzNzExZDY5YjgyMzIwNDk0ZDdlMTMzNA%253D%253D--74376da42dbe7eb36ecdec2879fbf0f38c5b0900; domain=.twitter.com; path=/; HttpOnly X-XSS-Protection: 1; mode=block Vary: Accept-Encoding Server: tfe Array ( => https://twitter.com/signup?foll... ( ) [redirect_url] => ) Array[/FONT][/COLOR]
     
    afimafis, Feb 4, 2012 IP