Forum Moderators: coopster

Message Too Old, No Replies

Yahoo Login using Curl

Yahoo Login

         

rahul anand77

5:29 am on Oct 7, 2009 (gmt 0)

10+ Year Member



Hello Everyone,
I am working on a script to login into your yahoo account using curl and without visiting to yahoo. I have got so many script and most of them has the same code(URL,Query String) posting. But that script is not working. That return me the Login page rather then the Inbox page. Please help me to solve this issue. It is reallya a big Issue. I am working on curl first time.

Thanks in Advance
Rahul Anand

[edited by: jatar_k at 4:07 pm (utc) on Oct. 7, 2009]
[edit reason] no contact info, thanks [/edit]

andrewsmd

3:16 pm on Oct 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I haven't ran this in a while but it used to work for me. However, I never got anything back, I was just posting data to the server. Hope this helps get you started
//this is the url of the page where the form is posted to
//make sure that it is example.com sometimes a form may
//be on example.com but it actually posts to example.com/submit.php
//or something like that
$url = "http://example.com";
//create array of data to be posted

//this is an array of the post ids you need
//and the values you want to pass im assuming
//the username password textbox is name username
//and the password textbox is name password
$post_data['username'] = 'username';
$post_data['password'] = 'password';

//traverse array and prepare data for posting (key1=value1)
foreach ($post_data as $key => $value) {
$post_items[] = $key . '=' . $value;
}

//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);

//create cURL connection
$curl_connection = curl_init($url);

//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);

//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);

//perform our request
$result = curl_exec($curl_connection);

//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . '-' . curl_error($curl_connection);

//close the connection
curl_close($curl_connection);