-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebhook.php
29 lines (26 loc) · 851 Bytes
/
webhook.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
include("api.php");
$a = new downloadgram();
$botToken = 'YOUR TOKEN';
$a->BotToken = $botToken;
$update = json_decode(file_get_contents("php://input"), TRUE);
if (isset($update["message"])) {
$chatId = $update["message"]["chat"]["id"];
$message = $update["message"]["text"];
$userInfo = json_decode(file_get_contents("https://api.telegram.org/bot$botToken/getChat?chat_id=$chatId"), true);
if ($userInfo && isset($userInfo['ok']) && $userInfo['ok']) {
$username = $userInfo['result']['username'];
$first_name = $userInfo['result']['first_name'];
if(isset($username) and $username !== null){
$a->username = $username;
}else{
$a->username = $first_name;
}
}
$a->chatid = $chatId;
echo $a->getCheck($message);
} else {
//error
die();
}
?>