I am trying to get points allocated to ma user based on the number of referrals, using the telegram bot by passing a payload to the /start command from where i can track it and know who has been referring people to the bot
i have tried following the documentation process and was able to set the command but i didn’t see a way of getting the payload
ini_set('error_reporting', E_ALL);
$token="870645666:AAHrjEF006uje1SpG0dFJRFnmfNIZHbGxdM";
$website ="https://api.telegram.org/bot".$token;
$update =file_get_contents("php://input");
$update =json_decode($update, TRUE);
$chatid =$update["message"]["chat"]["id"];
$message =$update["message"]["text"];
$refid=$update["message"]["text"]["payload"];
$ref=mysqli_fetch_assoc(mysqli_query($connect, "SELECT * FROM
bot where refid='$refid'"));
sendMessage($chatid, "You were referred by".$ref['name'];
function sendMessage($chatid, $message){
$url =$website."/sendMessage?
chat_id=".$chatid."&text=".urldecode($message);
file_get_contents($url);
}
There is no output for the payload when i try to access it
i have tried google but i can’t find a way to fetch the payload using php. Any help would be appreciated
2
Answers
https://core.telegram.org/bots#deep-linking
You can receive the payload in a normal text message that starts with “/start”
Telegram sends Payload inside the message content to your bot