I have seen very similar question a number of times & have tried them but I am not being able to get the result.
https://stackoverflow.com/questions/21369197/curl-login-vbulletin-cookie
Login to site with curl in vBulletin
....
I would really be grateful for someone who could help me in loging into the forums & able to view various posts.
So far, this is what I have done
$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);
If the I set curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
it returns a page which is not logged in, though the cookie has logged in information.
Ok, instead of using
file_get_contents($user_url)
. I usedphp_curl
& finally got the logged in pages.It might be helpful for someone having similar problem.