skip to Main Content

Not so long ago Telegram Bot API got updated with new features for webhook configuration. One of them is allowed_updates field which is array of strings.

It also has a possibility to set webhook with custom self signed certificate. You just need to post webhook configuration as multipart/form-data.

But how to post allowed_updates which is array of strings as multipart/form-data?

2

Answers


  1. you can post the allowed_updates array of strings by

    allowed_updates=["callback_query","inline_query"]
    

    You can set List the types of updates you want your bot to receive.
    here I set to only receive updates of these types:callback_query & inline_query

    https://api.telegram.org/bot<YOUR_API_TOKEN>/setwebhook?url=<HTTPS_url_to send_updates_to>&max_connections=20&allowed_updates=["callback_query","inline_query"]
    

    Here complete list of available update types.

    https://core.telegram.org/bots/api#update

    Login or Signup to reply.
  2. function MrPHPBot($method,$datas=[]){
        $url = "https://api.telegram.org/bot".{token}."/".$method;
        $ch = curl_init();
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$datas);
        $res = curl_exec($ch);
        if(curl_error($ch)){
            var_dump(curl_error($ch));
        }else{
            return json_decode($res);
        }
    }
    
    
    MrPHPBot('setWebhook',[ 'url'=>$url , 'certificate'=>new CURLFile(realpath("key.pem")) , 'allowed_updates'=> ['message', 'edited_channel_post','callback_query'] ]);    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search