[PHP] Log into WUpload using CURL

Code: 
<?php
set_time_limit(300);
error_reporting(0);
/**
* @author midoalone
* @copyright 2011
* @filename login.php
* @creationDate 5/11/2011
*/

#-- The main function to login the wupload.com --#
function wupload_login($email, $password, $url='http://www.wupload.com/account/login'){
    // Initiate the curl method
    $ch = curl_init();
   
    // Set the login url
    curl_setopt($ch, CURLOPT_URL, $url);
   
    // Prevent the print out of the received data
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   
    // Enable sending data with the POST method
    curl_setopt ($ch, CURLOPT_POST, 1);
   
    // Include the post variable that represt the login form elements
    curl_setopt ($ch, CURLOPT_POSTFIELDS, 'email='.$email.'&password='.$password);
   
    // Handle cookies and save them into a file
    curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
   
    // Excute the curl request
    $store = curl_exec ($ch);
   
    // Close curl
    curl_close ($ch);
   
    if($store == 1){
            echo "Unable to Login.";
    }else{
            echo "Logged In.";
    }   
}


#--- Function to load a url that need login --#
function loadUrl($url='http://www.wupload.com/account/settings'){
    $cr = curl_init($url);
    curl_setopt($cr, CURLOPT_RETURNTRANSFER, true);   
    curl_setopt($cr, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    // Use cookie.txt for READING cookies
    curl_setopt($cr, CURLOPT_COOKIEFILE, 'cookie.txt');
    $output = curl_exec($cr);
    curl_close($cr);
    echo $output;       
}
function UserInfo($email, $password)
{
    $url = "http://api.wupload.com/user?method=getInfo&u=$email&p=$password";
    $userinfo = curl_init($url);
    curl_setopt($userinfo, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($userinfo, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($userinfo, CURLOPT_COOKIEFILE, 'cookie.txt');
    $returnUserInfo = curl_exec($userinfo);
    $regex_id = '/id":(.+?),/';
    $regex_email= '/email":(.+?),/';
    $regex_nickname = '/nickname":(.+?),/';
    $regex_isPremium = '/"is_premium":(.+?)}/';
    preg_match($regex_id, $returnUserInfo, $match_id);
    preg_match($regex_email, $returnUserInfo, $match_email);
    preg_match($regex_nickname, $returnUserInfo, $match_nickname);
    preg_match($regex_isPremium, $returnUserInfo, $match_premium);
    echo "<br />User ID: ".$match_id[1]."<br />";
    echo "Email : ".$match_email[1]."<br />";
    echo "Nickname : ".$match_nickname[1]."<br />";
    echo "isPremium : ".$match_premium[1]."<br />";
}

UserInfo("vickkumar2011@gmail.com", "password");
?>
Original Article Link
http://forum.phpcanyon.net/index.php...ad-using-curl/
_Vick Reviewed by _Vick on . [PHP] Log into WUpload using CURL Log into WUpload using CURL <?php set_time_limit(300); error_reporting(0); /** * @author midoalone * @copyright 2011 * @filename login.php * @creationDate 5/11/2011 Rating: 5