Answer the question
In order to leave comments, you need to log in
Failed to receive SOCKS5 connect request ack. When accessing the Telegram Bot API via cURL?
I turn to the Telegram Bot API with cURL and there are times when it returns this error
Failed to receive SOCKS5 connect request ack.
There is no such problem on OpenServer.
Everything happens on a hosting (hts) with a trial period.
I can not understand what could be the problem ...
Here is the code
function sendMessage($imgUrl, $text, $link){
$ch = curl_init();
$pr = array('u0k12.tgproxy.me', 'sr.spry.fail', 'sr123.spry.fail', 'd2a5e5.reconnect.rocks');
$x= 0;
$cnt = count($pr);
do{
//Проверяем доступность proxy
$host = $pr[$x];
$port = 1080;
$waitTimeoutInSeconds = 1;
$x++;
if($fp = fsockopen($host,$port,$errCode,$errStr,$waitTimeoutInSeconds)){
$a = 1; //если ping proxy меньше 1 секунды
} else {
$a = 0;
}
fclose($fp);
}while($a !== 1);
$user = 'TELEGRAM';
$pas = 'TELEGRAM';
if($host == 'd2a5e5.reconnect.rocks')
{$pas = '11a1fcc2';$user = '3559738';}
$proxy = $user.":".$pas."@".$host.":".$port;
$url = "https://api.telegram.org/botToken/sendMessage?chat_id=Chatid&parse_mode=Markdown&text=text;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PROXY, "socks5://".$proxy);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
$err = curl_error($ch);
if (!empty($err))
return $err;
return $result;
}
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