Answer the question
In order to leave comments, you need to log in
Why does CURL only return true?
I make a request to get a set of products, I get only true, where is the error?
$url = "https://www.jab.de/ru/ru/productsearch";
$cookie = "cookie.txt";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if (curl_errno($ch)) die(curl_error($ch));
phpQuery::newDocument($response);
$token = pq("meta[name=_csrf]")->attr('content');
curl_setopt($ch, CURLOPT_POST, true);
$params = array(
'facet' => '',
'location' => "",
'pageSize' => 30,
'resultsNew' => 30,
'resultsDisplayed' => 30,
'searchTerm' => '',
'sortCode' => "recommendation",
);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
$headers = array (
"Connection: keep-alive",
"User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.162 Safari/535.19",
"Accept: application/json, text/javascript, */*; q=0.01",
"Accept-Encoding: gzip, deflate, br",
"Accept-Language: ru-RU,ru;q=0.9,en;q=0.8,en-GB;q=0.7,en-AU;q=0.6,en-US;q=0.5",
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3",
"Content-Type: application/json; charset=UTF-8",
"CSRFToken: $token",
"X-Requested-With: XMLHttpRequest",
);
curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$html = curl_exec($ch);
var_dump($html);
if (curl_errno($ch)) print curl_error($ch);
curl_close($ch);
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