国产99视频精品专区,国产欧美精品国产国产专区,中文字幕不卡二区亚洲,日本 在线 视频 中文 有码

<object id="oh9jj"><button id="oh9jj"></button></object>
    1. <dfn id="oh9jj"></dfn>

      Telegram機(jī)器人開發(fā)實(shí)例 php語(yǔ)言

      二次開發(fā) admin 發(fā)布時(shí)間:2024-03-01 16:34:35 瀏覽:

      現(xiàn)在Telegram中國(guó)人稱為飛機(jī)的機(jī)器人功能已經(jīng)非常強(qiáng)大了,不僅可以完成自動(dòng)回復(fù)信息,查詢訂單,還可以搭建商城完成支付,設(shè)置可以搭建一個(gè)簡(jiǎn)單的搜索引擎!?。柡Σ??哈拉哨不?

      現(xiàn)在說一下Telegram機(jī)器人的開發(fā)步驟和里面主要的坑,希望朋友們可以避免。
       
      1.首先聯(lián)系Botfather輸入命令/newbot 創(chuàng)建一個(gè)你自己的機(jī)器人。完成后會(huì)出現(xiàn)
      Done! Congratulations on your new bot. You will find it at t.me/milliondatabot. You can now add a description, about section and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.
       
      Use this token to access the HTTP API:
      6752959087:AAEwqjTj__dT5IwG1wMsG1_7iRTohTdDF1Q
      Keep your token secure and store it safely, it can be used by anyone to control your bot.
       
      For a description of the Bot API, see this page: https://core.telegram.org/bots/api
       
      這里面6752959087:AAEwqjTj__dT5IwG1wMsG1_7iRTohTdDF1Q就是機(jī)器人的秘鑰,妥善保存,不要泄露。
      以后所有開發(fā)機(jī)器人的功能都要用到這個(gè)秘鑰,也叫Token.是一回事。
       
      2.你需要設(shè)置一個(gè)webhook來處理機(jī)器人發(fā)來的消息。用下面的命令
      https://api.telegram.org/bot你的token/setWebhook?url=你的url地址
       
      這里你的url地址必須是https開頭的。因?yàn)門elegram只支持https的網(wǎng)址。
       
      3.就是在webhook里面的程序中寫入你自己的處理邏輯。
      比如根據(jù)機(jī)器人的消息來查詢訂單啥的。
       
      4.你處理好邏輯之后,需要把你的處理結(jié)果返回給機(jī)器人對(duì)話的群組。
      可以用下面的語(yǔ)句
      $url = "https://api.telegram.org/bot".$this->Token."/";
      $url=$url . "sendMessage?text=" . $result."&chat_id=" . $chat_id;
      file_get_contents($url);
       
      另外有一個(gè)坑,請(qǐng)大家注意,就是webhook的服務(wù)器最好用國(guó)外的,國(guó)內(nèi)的服務(wù)器好像網(wǎng)絡(luò)路由有問題,無法提交給Telegram API
       
      如果你們?cè)陂_發(fā)Telegram機(jī)器人上遇到問題,或者需要開發(fā)機(jī)器人相關(guān)功能,請(qǐng)聯(lián)系我
      QQ:804752009。
      相關(guān)推薦
        無相關(guān)信息

      在線咨詢

      點(diǎn)擊這里給我發(fā)消息售前咨詢專員

      點(diǎn)擊這里給我發(fā)消息售后服務(wù)專員

      在線咨詢

      免費(fèi)通話

      24h咨詢:0475-2793529


      如您有問題,可以咨詢我們的24H咨詢電話!

      免費(fèi)通話

      微信掃一掃

      微信聯(lián)系
      返回頂部