Answer the question
In order to leave comments, you need to log in
How to properly connect via cUrl with a proxy?
It seems that the connection to api vk was temporarily banned, I'm trying to send a request through a proxy
<?php
$str = 'https://api.vk.com/method/wall.get?.....';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $str);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.1) Gecko/2008070208');
curl_setopt($curl, CURLOPT_PROXY, 'ip:port');
curl_setopt($curl, CURLOPT_PROXYUSERPWD, 'user:pwd');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
$json = curl_exec($curl);
$curl_error_code = curl_errno($curl);
$curl_error_desc = curl_error($curl);
$curl_info = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($curl_error_code > 0) {
exit($curl_error_desc . ' (' . $curl_error_code . '); HTTP-код: ' . $curl_info);
}
curl_close($curl);
var_dump(json_decode($json));
Connection timed out after 10001 milliseconds (28); HTTP-код: 0
Answer the question
In order to leave comments, you need to log in
If I'm not mistaken, then different providers allow CURL options in different ways.
Most likely, CURL is disabled on this hosting.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question