php - cURL - not properly working with JSON requests or Not saving Session -
everyone!
i have 2 controllers meant search on websites. can search on them if logged in. so.. tracking post request , data goes file give answer , login page redirects normal logged in page.
first controller code
$ch = curl_init(); curl_setopt($ch, curlopt_url, self::loginurl); #curl_setopt($ch,curlopt_httpheader,$httpheader); curl_setopt($ch, curlopt_cookie, $cookie); curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_postfields, $postdata); curl_setopt($ch, curlopt_cookiesession, true); curl_setopt($ch, curlopt_returntransfer, false); curl_setopt($ch, curlopt_followlocation, true); curl_exec($ch);
so, goes loginurl, post data , displays 1, instead of website(with me logged in). 1 answer json file give successful login. problem not logged in, if set new curl handler home url. same problem goes second controller, code:
$ch = curl_init(self::loginurl); curl_setopt($ch, curlopt_cookiejar, 'cookie_'.self::site.'.txt'); curl_setopt($ch, curlopt_cookiefile , 'cookie_'.self::site.'.txt'); curl_setopt($ch, curlopt_cookie, $cookie); curl_setopt($ch, curlopt_referer, self::refurl); curl_setopt($ch, curlopt_post, 1); #curl_setopt($ch, curlopt_customrequest, "post"); curl_setopt($ch, curlopt_postfields, $postdata); curl_setopt($ch, curlopt_httpheader, $requestheaders); #curl_setopt($ch, curlopt_header, true); curl_setopt($ch, curlopt_followlocation, true); curl_setopt($ch, curlopt_returntransfer, false); $result = curl_exec($ch); curl_close($ch);
sorry if used bad indenting or bad english. have nice day!
edit: may come bad cookie using, because cookie file empty, advice on this, how test it?
Comments
Post a Comment