<?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");
?>
No replies to this topic
#1
Posted 23 November 2011 - 02:16 AM
[PHP] Log into WUpload using CURL
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
Sign In
Create Account
Back to top








