I am trying to log into my yahoo mail account using cURL. When i run the following code in my browser i get no errors, the page is displayed by my last $print result comand, but my post command does not fill in my username and password into the text fields.
Looking at the code, does anything stand out or is there something about the yahoo page that I am missing.
Thanks,
rfulky
<?php
$username = urlencode("XXXXXXX");
$password = "**********";
$cookie_file_path = "C:\wamp\www\cook.txt";
$LOGINURL = "http://mail.yahoo.com";
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec ($ch);
$v_error = curl_error($ch);
curl_close ($ch);
echo $v_error;
$LOGINURL = "https://login.yahoo.com/config/login_verify2?&.src=ym";
$reffer = "http://mail.yahoo.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=$username&passwd=$password");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec ($ch);
$c_error = curl_error($ch);
curl_close ($ch);
echo 'err= '.$c_error;
print $result;
?>