Referral links with Telegram bot

  Kiến thức lập trình

I want to capture referral links when a Telegram user share my bot’s link.

Example:

https://t.me/amazing_bot?ref=abcde

I want to get the ref value.

I read the Telegram doc but I can’t find how I can do this with PHP.

Ideally it would be nice if I could get the ref with my webhook.

For the moment, my webhook sends a message when the user joins my bot with the /start command.

webhook.php:

<?php
$path = "https://api.telegram.org/bot0000000:AAAAAA-BBB-CCCCC_DDDDD";

$update = json_decode(file_get_contents("php://input"), TRUE);

$chatId = $update["message"]["chat"]["id"];
$message = $update["message"]["text"];

if (strpos($message, "/start") === 0) {
    file_get_contents($path."/sendmessage?chat_id=".$chatId."&text=Hello World!");
}
?>

Any idea?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT