Telegram Bot PHP键盘不起作用

时间:2017-03-02 15:00:08

标签: bots telegram telegram-bot

我在为电报机器人创建自定义键盘时遇到问题。

简单地说,它不起作用,我不知道原因......

这是我的代码:

categories.collection.42.posts.collection.36

功能:“funzioneCiao($ chatId);”和“inviaMessaggio($ chatId,$ messaggio)”有效,但是, “TastieraMenuPrincipale($ chatId)”和“TastieraInLine($ ChatId)”不起作用。

我是PHP的初学者,所以我有很多困难...

谢谢。

2 个答案:

答案 0 :(得分:0)

我刚测试了代码,它运行得很完美......

enter image description here

答案 1 :(得分:0)

为什么不使用CURL代替file_get_contents();?!

只需将此函数写入代码,然后在获取新更新后调用它:

function makeHTTPRequest($method, $types = []){
    $url = 'https://api.telegram.org/bot'.$botToken.'/'.$method;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($types));
    $res = curl_exec($ch);
    if (curl_error($ch)){
        var_dump(curl_error($ch));
    } else {
        return json_decode($res);
    }
} 

确保在您的托管服务器上激活CURL!

相关问题