使用curl自动登录

时间:2013-10-19 11:29:23

标签: php curl

我正尝试使用以下方式自动访问“http://games.espn.go.com/fba/clubhouse?leagueId=xxxxx&teamId=8&seasonId=2014

$ebay_user_id = "username"; 
$ebay_user_password = "password"; 
$cookie_file_path = "crawler\ebay_login\cook";

$LOGINURL = "http://games.espn.go.com/fba/signin";
$POSTFIELDS = 'e=0&cookieDomain=.go.com&multipleDomains=true&username='. $ebay_user_id .'&password='. $ebay_user_password;

$reffer = "http://games.espn.go.com/fba/signin?redir=http%3A%2F%2Fgames.espn.go.com%2Ffba%2Fclubhouse%3FteamId%3D8%26leagueId%xxxxxx%26seasonId%3D2014"; 

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$LOGINURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$POSTFIELDS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_REFERER, $reffer);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$result = curl_exec ($ch);
curl_close ($ch);

我正在使用一个适用于ebay的示例。我应该把重点放在哪里让espn工作?在我的示例中,它会被重定向到一个“无效登录页面。请再试一次。”

0 个答案:

没有答案