skip to Main Content

I have this private telegram channel which I’ll charge for access (premium content). I just have found that now you can create a temporary invite link that expires by time or by number of clicks (see attachment). This would be great to automate my payment process as I could generate a unique link for each new customer that makes a payment, so they can only use once, and won’t be able to share to others.

Any ideas on how to generate this links using the API? This feature must be really new as I haven’t found anything in the documentation.

Many thanks in advance,
Ed

printscreen

2

Answers


    1. Open API docs
    2. Press CTRL+F (or CMD+F on Mac)
    3. Type link, press Enter and RTM

    Example:
    https://core.telegram.org/bots/api#createchatinvitelink

    Also look at the member_limit param for this method.

    Login or Signup to reply.
  1. See the php function for this problem:

    function createChatInviteLink($apiToken, $chat_id){
        $date = new DateTime();
        $date->modify('+12 month');
        $data = array(
                'chat_id' => $chat_id,
                'member_limit' => 1,
                'expire_date' => $date->getTimestamp()
            );
        $url = "https://api.telegram.org/bot$apiToken/createChatInviteLink";
    
        //  open connection
        $ch = curl_init();
        //  set the url
        curl_setopt($ch, CURLOPT_URL, $url);
        //  number of POST vars
        curl_setopt($ch, CURLOPT_POST, count($data));
        //  POST data
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        //  To display result of curl
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        //  execute post
        $result = curl_exec($ch);
        //  close connection
        curl_close($ch);    
        return $result;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search