2017-03-02 11 views
8

मैं टेलीग्राम बॉट विकसित कर रहा हूं, और मैं अपने डोमेन के यूआरएल में वेबहूक सेट करना चाहता हूं। मैंने Telegram's guide के बाद पहले से ही एक स्व-हस्ताक्षरित प्रमाणपत्र तैयार किया है। हालांकि, मैं webhook सेट करने में सक्षम नहीं हूँ। मैंने पिछले उत्तरों की खोज की है और this one पाया है, लेकिन यह मेरे लिए काम नहीं करता है। क्या कोई मुझे बता सकता है कि एसएसएल प्रमाणपत्र कैसे अपलोड करें और वेबहूक सेट करें?टेलीग्राम बॉट वेबहुक कैसे सेट करें?

धन्यवाद।

उत्तर

13

मैंने टेलीग्राम वेब्हूक्स को आसानी से स्थापित करने के लिए अपने सर्वर पर एक फाइल बनाई है।

आप अपने सर्वर पर एक ही फाइल का उपयोग कर सकते हैं।

यह एक ही सर्वर जिसमें से आप क्या आप बॉट की मेजबानी के लिए

  • सुनिश्चित माइम-प्रकार इच्छा टेलीग्राम बॉट

    <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 साथ फार्म भरें और चुने हुए पोर्ट
    4. आपकी प्रमाणपत्र फ़ाइल
    5. अपलोड फ़ॉर्म में जमा

    आप एक सफल परिणाम प्राप्त होगा:

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

    enter image description here

  • संबंधित मुद्दे