Php 使用电报api发送消息

Php 使用电报api发送消息,php,telegram,telegram-bot,php-curl,php-telegram-bot,Php,Telegram,Telegram Bot,Php Curl,Php Telegram Bot,我有一些PHP代码向电报机器人发送消息: $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

我有一些
PHP
代码向
电报机器人发送消息

$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);

我使用了
curl
,因为使用
file\u get\u contents()
fopen()
会导致
连接被拒绝
错误。但它仍然不起作用。我应该如何修复它?

有很多用于PHP Telegram API集成的Bot代码示例

请检查一下

机器人程序代码示例:

  • PHP电报API。一个完整的PHP7 Bot API实现 电报

  • PHP电报机器人。纯PHP电报机器人,可通过
    插件

  • Bot-API-PHP-SDK。支持Laravel的SDK。


    • 这里是用PHP编写的简单hello机器人