vBulletin卷曲登录重定向不工作(vBulletin Curl login redirect

2019-10-21 12:15发布

我所看到的非常类似的问题多次与曾尝试他们,但我不能够得到的结果。

https://stackoverflow.com/questions/21369197/curl-login-vbulletin-cookie

登录网站与vBulletin卷曲

....

我真的会有人谁可以帮助我在登录电子进入论坛与能够查看各个岗位感激。

到目前为止,这是我做了什么

$username="username"; 
$password="password"; 
$url="www.example.com/login.php?do=login"; 
$cookie="cookie.txt"; 


$postdata = "".

        'do=login'.
        '&s='.
        '&securitytoken=<security token here>'.
        '&vb_login_md5password=<md5 password here>'.
        '&vb_login_md5password_utf=<same as the one above>'.
        '&vb_login_password='.
        '&vb_login_password_hint=Password'.
        '&vb_login_username=username';


$ch = curl_init(); 
curl_setopt ($ch, CURLOPT_URL, $url); 
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;     rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 
curl_setopt ($ch, CURLOPT_TIMEOUT, 60); 
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); 
curl_setopt ($ch, CURLOPT_REFERER, $url); 
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); 
curl_setopt ($ch, CURLOPT_POST, 1); 

$result = curl_exec ($ch); 



echo $result;  
curl_close($ch);

如果我设置curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); 它返回它没有登录,但该cookie信息已登录的页面。

Answer 1:

好了,而不是使用file_get_contents($user_url) 我用php_curl &终于得到了在页面登录。

$ch = curl_init(); 

curl_setopt ($ch, CURLOPT_URL, $user_url); 
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 
curl_setopt ($ch, CURLOPT_TIMEOUT, 60); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); 
$result = curl_exec ($ch); 

curl_close($ch);


echo $result;  // the logged in page

这可能是有类似问题的人有帮助。



文章来源: vBulletin Curl login redirect not working