我是新手的概念CURL。現在我正在嘗試使用PHP curl來遠程登錄Facebook。我已提到Refer,Refer 1,Refer 3,Refer 4。但它並沒有明確表示我的懷疑。使用捲曲自動登錄到遠程網站php
我的代碼如下位置:
define('HOME' , dirname(__FILE__));
//Create a curl object
$ch = curl_init();
if(is_callable('curl_init')){
echo "Enabled"."<br>";
}
else
{
echo "Not enabled"."</br>";
}
$login_url = 'https://www.facebook.com/login/';
//These are the post data username and password
$post_data = array('email'=>'MY_EMAIL_ID','pass'=>'gdfgg');
//Set the useragent
$agent = $_SERVER["HTTP_USER_AGENT"];
//echo $agent;
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
//Set the URL
curl_setopt($ch, CURLOPT_URL, $login_url);
//This is a POST query
curl_setopt($ch, CURLOPT_POST, 1);
//Set the post data
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
//We want the content after the query
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Follow Location redirects
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
/*
Set the cookie storing files
Cookie files are necessary since we are logging and session data needs to be saved
*/
curl_setopt($ch, CURLOPT_COOKIEJAR, HOME. '/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, HOME. '/cookie.txt');
//Execute the action to login
$postResult = curl_exec($ch);
curl_close($ch);
echo $postResult;
當我在我的Firefox DOM部分檢查,它表明
在我cookie.txt,我沒有代碼的是,它代表空連儘管我將權限更改爲全部。
問題1:上面的代碼會做什麼?
問題2:如何檢查它在DOM中的工作與否?
問題3:它會在本地工作嗎?
您是否正在尋找使用Facebook登錄? (或社交網絡登錄API) –
是登錄Facebook使用捲曲 –
你爲什麼要通過捲曲來做到這一點?只需創建一個適當的登錄並存儲訪問令牌。 – luschn