could not login to iptorrents.com via Php Curl

Discussion in 'General Programming Chat' started by sohom, Apr 2, 2014.

  1. sohom

    sohom Senior Member

    Joined:
    May 26, 2013
    Messages:
    986
    Likes Received:
    175
    Location:
    not in Past
    Hello
    I used same method/code to logged into rapidgator.net
    and its working but some how its not working for iptorrents.com


    Code:
    <?php
    function curl_get_wp_login( $login_user, $login_pass, $login_url, $http_agent, $cookie_file ){
        // Preparing postdata for iptorrents login
        $data = "username=". $login_user ."&password=" . $login_pass;
    
        // Intialize cURL
        $ch = curl_init();
    
        // Url to use
        curl_setopt( $ch, CURLOPT_URL, $login_url );
        
        curl_setopt( $ch, CURLOPT_COOKIESESSION, 1 );
        // Set the cookies for the login in a cookie file.
        curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie_file );
    
        // Set SSL to false
        curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
    
        // User agent
        curl_setopt( $ch, CURLOPT_USERAGENT, $http_agent );
    
        // Maximum time cURL will wait for get response. in seconds
        curl_setopt( $ch, CURLOPT_TIMEOUT, 60 );
        
        curl_setopt($ch, CURLOPT_FAILONERROR, 1); 
        
        curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
    
        // Return or echo the execution
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
    
        // Set Http referer.
        curl_setopt( $ch, CURLOPT_REFERER, $login_url );
    
        // Post fields to the login url
        curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
        curl_setopt( $ch, CURLOPT_POST, 1);
    
        // Save the return in a variable
        $content = curl_exec ($ch);
    
        curl_close( $ch );
        echo $content;
        
    }
    
    // Username for login
    $login_user = "my_id";
    /*
    ** Password for this username
    */
    $login_pass = "my_pass";
    
    /*
    ** Login url address.
    */
    $login_url = "http://iptorrents.com/login.php";
    
    /*
    ** Cookie vaiable
    */
    $ckfile = dirname(__FILE__) . "/cookie2.txt";
    $cookie_file = fopen($ckfile, 'w') or die('Derp?open?nooooooooo!');
    /*
    ** Set HTTP user agent.
    */
    $http_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6";
    
    // Test the call
    curl_get_wp_login( $login_user, $login_pass, $login_url, $http_agent, $cookie_file );
    ?>
     
  2. bartosimpsonio

    bartosimpsonio Jr. VIP Jr. VIP

    Joined:
    Mar 21, 2013
    Messages:
    13,990
    Likes Received:
    12,505
    Occupation:
    MACHIN LURNIN
    Location:
    TUVALU
    Home Page:
    Check the server logs for any messages. Without more details it'll be impossible to help.