Answer the question
In order to leave comments, you need to log in
Why doesn't curl request work on linux server?
Hello everyone, I'm making a fucking parser with authorization on the site. But one problem.
On Windows, xampp is installed and everything is OK, authorization works, I see data from LAN - cookies are saved.
I make requests - they also work, I see all the information.
I throw files on the host and there I also get cookies, but authorization does not work, and throws it on the login form
function login($url){
$ch = curl_init();
if(strtolower((substr($url,0,5))=='https')) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"admin_login=Ivan_Ivanov&admin_password=123123&admin_key=321321");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (Windows; U; Windows NT 5.0; En; rv:1.8.0.2) Gecko/20070306 Firefox/1.0.0.4");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'].'/cookie.txt');
$result=curl_exec($ch);
var_dump($result);
//if(strpos($result,"Location: /work/")===false) die('Login incorrect');
curl_close($ch);
return $result;
}
login("https://site.ru/work/");
string(645) "HTTP/2 200 server: ddos-guard content-security-policy: upgrade-insecure-requests; set-cookie: __ddg1=yPaa9iSBxaywlYk6wvua; Domain=.site.ru; HttpOnly; Path=/; Expires=Sat, 19-Mar-2022 22:55:27 GMT date: Fri, 19 Mar 2021 22:55:27 GMT content-type: text/html; charset=UTF-8 x-powered-by: PHP/7.4.15
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question