hi
I'm trying to create a program that automatically logs in to Yahoo/AOL webmail (with my user and password).
I analyzed all they're hidden fields and all, and still something does not seem to work!!
if anyone here could help me i'd be greatful!
function HiddenFields($contents)
{
preg_match('/name="login_form">[\s\S]*yreglgtb/',$contents,$matches);
$str= implode(';',$matches);
$matches2= explode ('<',$str);
//------------ creating $params (all hidden fields) ------------
$names='';
$n=1;
while ($n+1 < count($matches2))
{
$str1=$matches2[$n];
preg_match('/name="[\s\S]*" value/',$str1,$match);
$value = str_replace('name="','',$match[0]);
$value = str_replace('" value','',$value);
$names.=$value.';';
$n++;
}
$names = explode (';',$names);
$values='';
$n=1;
while ($n+1 < count($matches2))
{
$str1=$matches2[$n];
preg_match('/value="[\s\S]*">/',$str1,$match);
$value = str_replace('value="','',$match[0]);
$value = str_replace('">','',$value);
$values.=$value.';';
$n++;
}
$values = explode (';',$values);
$params='';
$n=0;
while ($n+1 < count($names))
{
$params.=$names[$n].'='.$values[$n].'&';
$n++;
}
return $params;
} //HiddenFields
this function takes all the hidden fields in the specific login form and returns it into $params as $params='name=value&name2=value2....'
$varURL1 = 'https://login.yahoo.com/config/mail';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
//curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_URL,$varURL1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
//curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$contents=curl_exec($ch);
curl_close($ch);
$params = HiddenFields($contents);
$params.= 'login='.$username;
$params.= '&passwd='.$password;
$params.= '&.save=Sign In';
$varURL2='https://login.yahoo.com/config/login?';
$varURL2='https://login.yahoo.com/config/login?';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_REFERER, $varURL1 );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_URL,$varURL2);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
echo $content=curl_exec($ch);
curl_close($ch); ?>
thanks!