我试图登录" http://fourse.com/automation/Page/Login"并获取新支持'页面,但它不工作!和输出结果只是登录页面...你可以看到用户名和密码,随意查看网站结构 - 我正在尝试其他6个CURL登录示例,但都失败了。 这是我的最后一次机会,我的代码是:
/* Login part of the code -- start */
$cookie_file_path = getcwd() . '/cookie.txt';
//Emulating Firefox Browser:
$agent = $_SERVER['HTTP_USER_AGENT'];
//First, get and write session cookie:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://fourse.com/automation/Page/Login');
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$loginpage_html = curl_exec ($ch);
curl_close ($ch);
//Now, use the session cookie to actually log in:
$POSTFIELDS = "username=esmaeili&password=183791";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://fourse.com/automation/support/new-support');
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$POSTFIELDS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_REFERER, 'http://fourse.com/automation/support/new-support');
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
$logon_result = curl_exec ($ch);
curl_close ($ch);
echo $logon_result;
答案 0 :(得分:-1)
表格的隐藏字段名为" login"你没有提交。