Curl php doesn't authorize first time.Second time it does -
i have code authorize on site.if set cookies first time,it works.
$useragent = 'mozilla/5.0 (x11; ubuntu; linux x86_64; rv:18.0) gecko/20100101 firefox/18.0'; $url = 'http://hh.ru/'; $url_login = 'https://hh.ru/logon.do'; $login = ''; $password = ''; $ch = curl_init(); curl_setopt($ch, curlopt_failonerror, 0); curl_setopt($ch, curlopt_useragent,$useragent); curl_setopt($ch, curlopt_referer,'https://hh.ru/logon.do'); curl_setopt($ch, curlopt_autoreferer,1); curl_setopt($ch, curlopt_httpheader, array('expect:')); curl_setopt($ch, curlopt_ssl_verifypeer, 0); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_cookiejar, 'so.txt'); curl_setopt($ch, curlopt_cookiefile, 'so.txt'); curl_setopt($ch, curlopt_followlocation, 1); curl_setopt($ch, curlopt_unrestricted_auth, 1); curl_setopt($ch, curlopt_timeout, 999); curl_setopt($ch, curlopt_url,$url); curl_setopt($ch, curlopt_url,$url_login); $form = array('username'=>$login,'password'=>$password,'remember'=>'on'); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, $form); $result=curl_exec($ch); echo $result;
when run script again,it work.and again,if change "so.txt" @ other file,it won't work first time,and work second.
Comments
Post a Comment