我尝试使用以下代码登录网站。它有一个弹出消息
“虽然此页面已加密,但您输入的信息将通过未加密的连接发送,并且很容易被第三方读取。您确定要继续发送此信息吗?”
在授予访问权限之前,需要单击“继续”按钮。
代码不起作用,我不确定它是否与消息有关,或者我没有做对什么?
$url = "https://anothersite.com/login.php";
$agent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/A.B (KHTML, like Gecko) Chrome/X.Y.Z.W Safari/A.B.";
$username = "xxxx";
$password = "1234";
$postfields = "username=".$username."&password=".$password;
$cookie_file_path = getcwd().'/cookie.txt';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_POST, 1);
echo curl_exec($ch);
curl_close($ch);