我从来没有做过这样的事情......我想登录到swagbucks.com并获取一些信息,但它不工作。有人能告诉我我的脚本有什么问题吗?试图用PHP和cURL登录站点?
<?php
$pages = array('home' =>
'http://swagbucks.com/?cmd=home',
'login' =>
'http://swagbucks.com/?cmd=sb-login&from=/?cmd=home',
'schedule' =>
'http://swagbucks.com/?cmd=sb-acct-account&display=2');
$ch = curl_init();
//Set options for curl session
$options = array(CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; `rv:1.9.2) Gecko/20100115 Firefox/3.6',`
CURLOPT_HEADER => TRUE,
//CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_COOKIEFILE => 'cookie.txt',
CURLOPT_COOKIEJAR => 'cookies.txt');
//Hit home page for session cookie
$options[CURLOPT_URL] = $pages['home'];
curl_setopt_array($ch, $options);
curl_exec($ch);
//Login
$options[CURLOPT_URL] = $pages['login'];
$options[CURLOPT_POST] = TRUE;
$options[CURLOPT_POSTFIELDS] = '[email protected]&pswd=jblake&persist=on';
$options[CURLOPT_FOLLOWLOCATION] = FALSE;
curl_setopt_array($ch, $options);
curl_exec($ch);
//Hit schedule page
$options[CURLOPT_URL] = $pages['schedule'];
curl_setopt_array($ch, $options);
$schedule = curl_exec($ch);
//Output schedule
echo $schedule;
//Close curl session
curl_close($ch);
?>
但它仍然没有登录我。怎么了?
您可能需要审查您的个人信息。 – gpmcadam 2010-03-17 15:28:59
+1不给我们真正的凭据 – Axarydax 2010-03-17 15:30:20
也许他们正在检查http referer标题,如果你是从他们的登录表单来的?所以,尝试添加该标题。 – 2010-03-17 15:34:16