-1

I have some PHP code to sending message to Telegram_bot:

$telegrambot = "xxxxxxx"; 
$website="https://api.telegram.org/bot".$telegrambot; 
$chatId=yyyyyyy; 
$params=array('chat_id'=>$chatId,'text'=>$msg,);    

$ch = curl_init($website . '/sendMessage'); 
curl_setopt($ch, CURLOPT_HEADER, false); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, ($params)); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
$result = curl_exec($ch); 
curl_close($ch);

I used curl because using file_get_contents() or fopen() causes connection refused error. But still it doesn't work. How should I fix it?

Avan
  • 25
  • 1
  • 2

2 Answers2

1

There are lots of Bot Code Examples available for PHP Telegram API integration.

Please check it.

Bot Code Examples: https://core.telegram.org/bots/samples

Jayson
  • 1,105
  • 7
  • 25
0

Here is the simple hello bot which is written in PHP.

https://core.telegram.org/bots/samples/hellobot

Abduvokhid
  • 46
  • 1
  • 4