jozard Posted January 21, 2007 Share Posted January 21, 2007 hiI'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![sup]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 [/sup]this function takes all the hidden fields in the specific login form and returns it into $params as $params='name=value&name2=value2....' [sup]$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); ?>[/sup]thanks! Link to comment https://forums.phpfreaks.com/topic/35111-curl-login-to-yahoo-webmail/ Share on other sites More sharing options...
utexas_pjm Posted January 21, 2007 Share Posted January 21, 2007 Did you check that a cookie file is indeed being created per your curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); options, and that the data inside looks reasonable? Best,Patrick Link to comment https://forums.phpfreaks.com/topic/35111-curl-login-to-yahoo-webmail/#findComment-165753 Share on other sites More sharing options...
jozard Posted January 21, 2007 Author Share Posted January 21, 2007 yeah it creates a file with correct content.I dont think i need the line [sup]curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); [/sup]. I tried with it and without it, does the same. Link to comment https://forums.phpfreaks.com/topic/35111-curl-login-to-yahoo-webmail/#findComment-165759 Share on other sites More sharing options...
jozard Posted January 25, 2007 Author Share Posted January 25, 2007 if anyone knows something about hotmail/aol it would also be great Link to comment https://forums.phpfreaks.com/topic/35111-curl-login-to-yahoo-webmail/#findComment-168892 Share on other sites More sharing options...
devsanctum Posted December 6, 2008 Share Posted December 6, 2008 Did you ever get this working? Link to comment https://forums.phpfreaks.com/topic/35111-curl-login-to-yahoo-webmail/#findComment-708050 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.