我想登录www.z8games.com并转到设置页面,这是我使用的代码,错误如下。cURL登录和重定向[这是一个ASP.net页面]
<?php
$url = 'http://www.z8games.com/loging/globelogin.aspx?b=4&from=';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$html = file_get_contents($url);
preg_match('~<input type=\"hidden\" name=\"__VIEWSTATE\" id=\"__VIEWSTATE\" value=\"(.*?)\" />~',$html,$viewstate);
preg_match('~<input type=\"hidden\" name=\"__EVENTVALIDATION\" id=\"__EVENTVALIDATION\" value=\"(.*?)\" />~',$html,$eventvalidation);
$vstate = $viewstate[1];
$eval = $eventvalidation[1];
$post_fields='__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=' . urlencode($vstate) . '&__EVENTVALIDATION=' . urlencode($eval) . '&tb_loginid=Heroboss123&tb_password=Droppers1&ib_login.x=11&ib_login.y=19';
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7s");
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_COOKIEJAR, '/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, '/cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Changing from page
curl_setopt($ch, CURLOPT_URL, "http://www.z8games.com/myaccount/myaccount.aspx");
$store = curl_exec($ch);
echo $store;
curl_close($ch);
?>
它返回:
那么,您是否尝试启用“调试模式”建议?你甚至可以访问aspx页面吗? 'z8games'甚至是你的网站? –
它违反了z8games使用条款,所以也许你不应该这样做。 – 2014-01-15 19:06:03
我没有看到任何关于登录到他们的网站。 – Joery