爲你的下一份工作:)經過一些衝浪後,我發現a script你(有時候是我)需要。
/*
* Login to facebook
* $login_email : Account to login with
* $login_pass : Account password
*
* Returns true if logged in successfully, false otherwise
* Echoes any login error code
*
* Matt Smith - geekalicio.us
* Apr 23, 2009
*/
function fb_login($login_email, $login_pass){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?login_attempt=1');
curl_setopt($ch, CURLOPT_POSTFIELDS,'charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&locale=en_US&email='.urlencode($login_email).'&pass='.urlencode($login_pass).'&pass_placeholder=&charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, str_replace('\\','/',dirname(__FILE__)).'/fb_cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, str_replace('\\','/',dirname(__FILE__)).'/fb_cookies.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 GTB5");
curl_exec($ch);
$err = 0;
$err = curl_errno($ch);
curl_close($ch);
if ($err != 0){
echo 'error='.$err."\n";
return(false);
} else {
return(true);
}
}
,然後你可以用
if (fb_login($login_email,$login_pass)){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?login_attempt=1');
curl_setopt($ch, CURLOPT_POSTFIELDS,'charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&locale=en_US&email='.urlencode($login_email).'&pass='.urlencode($login_pass).'&pass_placeholder=&charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, str_replace('\\','/',dirname(__FILE__)).'/fb_cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, str_replace('\\','/',dirname(__FILE__)).'/fb_cookies.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 GTB5");
$html = curl_exec($ch);
curl_close($ch);
echo $html;
}
整個腳本我使用的是位於http://pastie.org/619912加載主頁。
是的,使用它的好,而不是爲了邪惡:)
出於好奇,你會用什麼?聽起來像是對我的可疑垃圾行爲...? – 2009-04-29 09:45:56
我在getafreelancer上找到了這份工作,我以爲他們首先需要自動登錄。現在,我無法完成這個項目,我真的沒有找到方法。 Spammish?我不知道他們到底需要什麼。但我可以想象許多非輪詢的原因。對於垃圾郵件,它會捲曲。但是我也開發了很多垃圾郵件,最終......我不在乎。這是古典的黑帽與白帽的兩難境地。最後,WH技術非常可靠,人們只關心金錢。我不是說它是正確的..它就是這樣。 – neon 2009-04-29 11:14:36