Hello, I can not understand why the query cURL does not return anything, even checked for an error curl_error does not output anything either. What is wrong here? Please help someone understand the topic. By the way, I used the Burp Suite program to track headers; for some reason, there is no 200 in the request status, I don’t know if it matters. Here is my code, password and login, I do not write:
<?php require_once 'vendor/autoload.php'; function request( $url, $post = null, $cookiefile = 'tmp/cookie.txt' ){ $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36'); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile); //curl_setopt($ch, CURLOPT_POST, 1); //curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json; charset=UTF-8', 'X-Requested-With: XMLHttpRequest', 'Accept-Encoding: gzip, deflate', 'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4', 'Accept: application/json, text/javascript, */*; q=0.01', 'Connection:keep-alive', 'Content-Length:122', 'Origin: http://www.3dcontentcentral.com', ]); curl_setopt($ch, CURLOPT_REFERER, 'http://www.3dcontentcentral.com/default.aspx'); curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8080'); curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); if( $post ){ curl_setopt( $ch, CURLOPT_POSTFIELDS, $post ); } if(curl_exec($ch) === false){ echo 'Ошибка curl: ' . curl_error($ch); }else{ echo 'Операция завершена без каких-либо ошибок'; } $html = curl_exec($ch); curl_close( $ch ); return $html; } file_put_contents('tmp/cookie.txt',''); $post = '{'.'"loginData":'.json_encode([ 'Login' => 'mylogin', 'Password' => "mypass", 'RememberMe' => false, 'LoginAsSupplier'=> false, 'CatalogId' => "" ]).'}'; $html = request('http://www.3dcontentcentral.com/default.aspx/Login', $post); echo $html;
if (($html = curl_exec($curl)) !== false && $html !== '') {}What is that no echo is displayed? - Jean-Claude