restrictChatMember not Working

(Hali Iliya) #1

Hello everybody :slight_smile:

I’m beginner working with Telegram bot.

I’m trying to making an application that do many things as i want.

So today i trying with method restrictChatMember and it is not working with me!

Here is my PHP - CURL connection code.

$API_KEY = "*** MY-BOT-TOKEN ***";

define("API_KEY",$API_KEY);

function bot($method,$data=[]){
$url = "https://api.telegram.org/bot".API_KEY."/".$method;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
curl_setopt($handle, CURLOPT_POST, true);
    $res = curl_exec($ch);
    if(curl_error($ch)){
        var_dump(curl_error($ch));
    }else{
        return json_decode($res);
    }
}
$update = json_decode(file_get_contents("php://input"));
$message = $update->message;

$text = $message->text;
$chatId = $message->chat->id;
$replyToMessageId = $message->reply_to_message->from->id;

And here is my other code

    if($text == "/p" and $ifReply){
            bot("restrictChatMember",[
            'chat_id' => $chatId,
            'user_id' => 819147475,
            'permissions' => [
                'can_send_messages' => false,
                'can_send_media_messages' => false,
                'can_send_polls' => false,
                'can_send_other_messages' => false,
                'can_add_web_page_previews' => false,
                'can_invite_users' => false,
                //'can_pin_messages' => false,
                //'can_change_info' => false,
            ]
        ]);
    }

Note: There have other methods not works such ( setChatPermissions ) and ( promoteChatMember ) and etc.

(ericb) #2

Hello Hali,

It appears you want to create a Telegram Bot. It will be best if you refer to Telegram’s support community as this forum is exclusive for FlowXO users only.

Thanks