Jump to content

curl login script


th.dude

Recommended Posts

hey guys,

 

I've been trying to make a curl login script for a czech web page http://login.szn.cz/?disableSSL=1&loggedURL=http://email.seznam.cz/ticket&serviceId=email&forceSSL=0 whole day and still can't figure it out. After you post the correct credentials, you are redirected to series of pages with meta refresh tag in it that need to be followed. So far any of my attempts has failed, so I'd really appreciate any help

 

Although the page doesn't have eniglish alternative it shouldn't be a problem, there is just one form where you submit info, dummy creds that I use do work, if you wanted to check the headers passed.

 

This is the last function I ended up with...

$url = "http://login.szn.cz/loginProcess";
$cookie = "cookie.tmp";
$post = 'username=Nafta.Nafta&domain=seznam.cz&password=Ropa&login=P%C5%99ihl%C3%A1sit+se&serviceId=email&disableSSL=1&forceSSL=0&lang=cz&loginType=seznam&returnURL=http%3A%2F%2Femail.seznam.cz%2Fticket&forceRelogin=0&coid=';
$u_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";


$url1 = request($url,1,"http://seznam.cz/");
$url2 = request($url1,0,0,$url1,1);


function request ($url,$post,$ref,$return){

$ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, $u_agent);

if ($post == 1){
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS,$post); 
}
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $ref);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
    $result = curl_exec($ch);
    curl_close ($ch); 
preg_match('/<a href=\"(.*?)\"/',$result,$match);
return $match[1];

}

 

Also I tried to request a page with valid user cookies, which for some reason doesn't work either.

Again any assistance would be greatly appreciated.

Cheers

Link to comment
https://forums.phpfreaks.com/topic/177784-curl-login-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.