2017-03-02 17 views
8

私はTelegramボットを開発しています。ウェブフックを自分のドメインのURLに設定したいと思います。私は既にTelegram's guideの後に自己署名証明書を生成しました。しかし、私はwebhookを設定することができません。以前の回答を検索したところ、this oneが見つかりましたが、それは私にとっては役に立ちません。誰も私のSSL証明書をアップロードし、webhookを設定する方法を私に説明することはできますか?Telegram bot webhookを設定するには?

ありがとうございました。

答えて

13

テレグラフウェブフックを便利に設定するために私のサーバーにファイルを作成しました。

サーバー上で同じファイルを使用できます。

これはあなたが

  • MIMEタイプを確認してくださいあなたのボットをホストする電報ボット

    <html> 
    
    <head> 
        <title>Set Webhooks</title> 
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" /> 
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.0/css/bulma.min.css" /> 
        <script src="https://unpkg.com/vue/dist/vue.js"></script> 
    </head> 
    
    <body> 
        <div class="container"> 
        <div id="app" class="section"> 
         <form :action="set_webhook" method="post" enctype="multipart/form-data"> 
         <label class="label">Enter your Token</label> 
         <p class="control"> 
          <input class="input" type="text" v-model="token" /> 
         </p> 
         <label class="label">Enter your Host</label> 
         <p class="control"> 
          <input class="input" type="text" v-model="host" /> 
         </p> 
         <label class="label">Enter your Port</label> 
         <p class="control"> 
          <input class="input" type="text" v-model="port" /> 
         </p> 
    
         <input type="hidden" name="url" v-model="bot_url"> 
         <label class="label">Maximum Connections?</label> 
         <p class="control"> 
          <input class="input" type="text" name="max_connections" value="100" /> 
         </p> 
         <br/> 
         <p style="color:blue">{{ bot_url }}</p> 
         <br/> 
         <label class="label">Enter your Certificate</label> 
         <p class="control"> 
          <input type="file" name="certificate" id="fileToUpload" /> 
         </p> 
         <br/> 
         <div class="control is-grouped"> 
          <p class="control"> 
          <button class="button is-primary" name="submit">Set Webhook</button> 
          </p> 
          <br/> 
          <p class="control"> 
          <a :href="get_webhook_info" target="_blank" class="button is-info">Get Webhook Info</a> 
          </p> 
         </div> 
        </div> 
        </div> 
        <script> 
        new Vue({ 
         el: '#app', 
         data: { 
         token: 'xxx', 
         port: 88, 
         host: 'your-server.com', 
         }, 
         computed: { 
         get_webhook_info: function() { 
          return 'https://api.telegram.org/bot' + this.token + '/getwebhookinfo' 
         }, 
         set_webhook: function() { 
          return 'https://api.telegram.org/bot' + this.token + '/setwebhook' 
         }, 
         bot_url: function() { 
          return 'https://' + this.host + ':' + this.port + '/' + this.token 
         } 
         } 
        } 
    
        ) 
        </script> 
    </body> 
    
    </html> 
    
    1. ドロップ同じサーバー上でこのファイルを実行したいのと同じサーバー上にある必要があり.pemのためにブラウズは、当社のサーバー
    2. にこのページへ
    3. あなたのウェブサーバ上で有効になっているあなたのBOT_TOKENと選択したPORT
    4. でフォームを記入
    5. あなたが成功した結果を取得するフォーム

    を提出

  • 証明書ファイルをアップロードします。

    {"ok":true,"result":true,"description":"Webhook was set"} 
    

    enter image description here

  • 関連する問題