PHP卷曲会话cookie登录SSL(错误)(PHP Curl session cookie SSL

2019-10-21 12:49发布

PHP卷曲会话cookie登录SSL(错误)

我没有任何麻烦,与其他网站做的事情。

我得到登录后错误prossing请求。 登录页面要求用户名/密码和令牌

(这是改变了很多不同的配置,使其工作,但没有运气)HTTP辗转来到XXXX能够发布

$curl = curl_init();
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 10; Windows NT 8.1)");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_COOKIEFILE, "cooker.txt");
curl_setopt($curl, CURLOPT_COOKIEJAR, "cooker.txt"); # SAME cookiefile




curl_setopt($curl, CURLOPT_URL, "XXXX.k.com/?nf=3&nf=4&siteID=0&WT.mc_id=0");
$xxx = curl_exec($curl);

preg_match_all('/name=\"token\" value=\"(.*?)\">/is', $xxx, $matches); 
foreach($matches[1] as $token) 
print $token;


curl_setopt($curl, CURLOPT_URL, "XXX.k.com/consumers/loginSubmitAction.do"); # this is where you first time connect - GET method authorization in my case, if you have POST - need to edit code a bit
curl_setopt($curl, CURLOPT_POSTFIELDS, "MYEMAIL%        40DOMAIN.com&password=MYPASSWORD&token=$token&sslRedirect=noRedirect");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 5.1)");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_COOKIEFILE, "cooker.txt");
curl_setopt($curl, CURLOPT_COOKIEJAR, "cooker.txt"); # SAME cookiefile
$xxx = curl_exec($curl);



preg_match_all('/name=\"token\" value=\"(.*?)\">/is', $xxx, $matches); 
foreach($matches[1] as $token) 
print $token;


curl_setopt($curl, CURLOPT_URL, "http://www.k.com/consumers/reportSubmitAction.do");     curl_setopt($curl, CURLOPT_POSTFIELDS, "vin=$vin&$token&sslRedirect=noRedirect");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 5.1)");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_COOKIEFILE, "cooker.txt");
curl_setopt($curl, CURLOPT_COOKIEJAR, "cooker.txt"); # SAME cookiefile
$xxx = curl_exec($curl);

echo $xxx;

curl_close ($curl);
文章来源: PHP Curl session cookie SSL login (error)