A
A
AndWEB2019-01-08 18:44:50
PHP
AndWEB, 2019-01-08 18:44:50

Telegram API not working, how to fix it?

I'm sending orders from the site to telegrams,
it doesn't work, the problem is due to blocking in the Russian Federation, the server seems to be located there.

$sendToTelegram = fopen("https://api.telegram.org/bot{$token}/sendMessage?chat_id={$chat_id}&parse_mode=html&text={$txt}","r");

Googled it and did it through a proxy, like this
$url = "https://api.telegram.org/bot{$token}/sendMessage?chat_id={$chat_id}&parse_mode=html&text={$txt}";

$ch = curl_init();
$proxy = "138.68.76.27:1080";
$optArray = array(
  CURLOPT_URL => $url,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_PROXY =>  "socks5://$proxy"
);
    curl_setopt_array($ch, $optArray);
    $result = curl_exec($ch);
    echo json_encode(['status' => 'success']);

But this method does not work very stable, sometimes a message comes, sometimes not. How to fix this, where to get a proxy, and how else can I fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Shumov, 2019-01-08
@AndWEB

Starting a server in the neutral zone is not an option, is it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question