Forum Moderators: coopster
I m working on a module where i want to write a script which when run should allow me to login to a perticular site, which i call remote login (dont know if its right or wrong).
Can we do this in PHP?
I heard something called CURL...can we do it using this?
e.g.
suppose i have www.yahoo.com
and i want to login to yahoo from my program..may be passing some username and password in a string and then I want to retrieve inner page content.
I have valid username and password of the site I want to work.
Please Guide me people.
Thanking you in advance.
$ch = curl_init();
$agent=$_SERVER["HTTP_USER_AGENT"];
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
$data = curl_exec($ch);
Yahoo sometimes doublechecks your password, so you might want to open a second curl session after the first one, and send the same string to $url = 'https://login.yahoo.com/config/login_verify2'; ... just to make sure ;-)
Welcome to WebmasterWorld, both of you ;)