I’m currently trying to write a script that will connect to a site using cURL.
I lookod for the ways to do that, and tried cookies, but I didn’t know what cookie is the login cookie… if anyone can help thanks…
But I tried another way… Using CURLOPT_POSTFIELDS but than I found out that the site is using GET on the login form (WHAT?!) So I tried this:
$username="User";
$password="Pass";
$url="http://www.site.com/register/?action=login&user=".$username."&password=".$password;
$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, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($ch);
echo $result;
curl_close($ch);
But it didn’t work… Is there any way to login to a site differently? The site has “method=GET” but it’s not really using get…
<form method="get" action="/register/" name="connectform">
<input type="hidden" name="action" value="login"/><input type="hidden" name="returnpage" value=""/>
<ul class="login_form">
<li><label>login :</label> <input type="text" name="login_login" maxlength="24" value="" class="input2"/><span class="error"></span></li>
<li><label>Password :</label> <input type="password" name="login_password" maxlength="24" value="" class="input2"/><span class="error"></span></li>
</ul>
<div class="login_button" style="display:inline-block">
<a class="small_button" onclick="javascript:document.connectform.submit()"><span>Connect to my account</span></a>
<input type="submit" style="display:none" />
</div>
</div>
</form>
What should I do?
I don’t care wich of these ways you’ll help me but I prefer the cookies way…
Thank you very much!
Try with following url:
Also add these options:
And if you want to get to other pages that require the login above, use following options:
Solution: Look at the comments below.