M
M
momoto2017-06-06 08:37:51
proxy
momoto, 2017-06-06 08:37:51

How to solve to avoid error in curl?

Hello.
Using curl, I send a request to a site with the https protocol.
Code for authorization on the site:

$arg = array("id"=>"1496505459", "login"=>"login", "password"=>"passw", "code"=>"1c41a1cc1c91148a0f3a5cb0490cd09e");
    
    $proxy = '185.148.216.147:8081';

  $ch = curl_init();

  $url = 'https://mysite.ru';

  $uagent = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36";

  curl_setopt($ch, CURLOPT_URL, $url ); // отправляем на
  curl_setopt($ch, CURLOPT_USERAGENT, $uagent);  // useragent
  curl_setopt($ch, CURLOPT_HEADER, 0); // пустые заголовки
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // возвратить то что вернул сервер
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // следовать за редиректами
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);// таймаут
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);// просто отключаем проверку сертификата
  curl_setopt($ch, CURLOPT_POST, 1); // использовать данные в post

    curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookie/'.$arg["code"].'.txt'); // сохранять куки в файл
    curl_setopt($ch, CURLOPT_COOKIEFILE,  dirname(__FILE__).'/cookie/'.$arg["code"].'.txt');

    curl_setopt($ch, CURLOPT_PROXY, $proxy);
    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); 

  
  curl_setopt($ch, CURLOPT_POSTFIELDS, array("login"=>$arg["login"],"password"=>$arg["password"]));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);

    $content = curl_exec( $ch );
    $err     = curl_errno( $ch );
    $errmsg  = curl_error( $ch );
    $header  = curl_getinfo( $ch );
    curl_close( $ch );

    $header['errno']   = $err;
    $header['errmsg']  = $errmsg;
    $header['content'] = $content;


Why does it give an error in response:
[errno] => 56
    [errmsg] => Received HTTP code 400 from proxy after CONNECT
    [content] =>


Prompt, with what it can be connected?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question