PHP/cURL POST to Chat

Discussion in 'PHP' started by thesurface, Oct 8, 2013.

  1. #1
    I am trying to connect to cryptochat.pw chat service via php but i cant, can you tell me whats going wrong pls.

    I am trying to connect to cryptochat.pw chat service via php but i cant, can you tell me whats going wrong pls.
    
    <?php
    $curl_header = array('X-Requested-With: XMLHttpRequest');
      // POST the login details along with other required details to the login process page
      $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL,'http://cryptochat.pw/');
            curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_header);
            curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 2);
            curl_setopt($ch, CURLOPT_POST,2);
            curl_setopt($ch, CURLOPT_POSTFIELDS,urlencode('nick=test&name=aWJuRXozaWhBWHVIODZIY3QrbUJXbGtpTElqazUwUGZEbEU3TzduaUl2UGwzVnU4c2dXYnFtaXVyellSRXZWc2dTQzdQQXdUTXhrMDd1NHZQa1hPQ3c9PQ'));
            curl_setopt($ch, CURLOPT_COOKIEJAR, './cookies1.txt');
            curl_setopt($ch, CURLOPT_COOKIEFILE, './cookies1.txt');
      curl_exec($ch);
    
      // Once logged in, we use the same Cookies to allow us to view the home page
      // Change the url to point to any page within the InvisionPower website that requires login
      $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, "http://cryptochat.pw/index.php?chat=aWJuRXozaWhBWHVIODZIY3QrbUJXbGtpTElqazUwUGZEbEU3TzduaUl2UGwzVnU4c2dXYnFtaXVyellSRXZWc2dTQzdQQXdUTXhrMDd1NHZQa1hPQ3c9PQ&pos=0");
            curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_header);
            curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_COOKIEJAR, './cookies1.txt');
            curl_setopt($ch, CURLOPT_COOKIEFILE, './cookies1.txt');
      $result = curl_exec($ch);
    echo $result;
      // Close the cURL to free up resources
      curl_close($ch);
    ?>
    PHP:

     
    thesurface, Oct 8, 2013 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    no result? please tell us more info, and try adding error_reporting(E_ALL);
     
    EricBruggema, Oct 9, 2013 IP
    ROOFIS likes this.