forked from DigiPlatMOOC/TelegramBotSample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhook.php
More file actions
35 lines (31 loc) · 915 Bytes
/
hook.php
File metadata and controls
35 lines (31 loc) · 915 Bytes
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
30
31
32
33
34
35
<?php
/*
* Telegram Bot Sample
* ===================
* UWiClab, University of Urbino
* ===================
* Basic message processing webhook end-point for your bot.
* Start editing here. =)
*/
include ('lib_msg_processing.php');
// Get input contents
// Notice: we use php://stdin (the HTTP request body) normally, but switch
// over to php://stdin (standard input channel) when running from
// command line, in order to let you test the script via input pipe
$content = file_get_contents((php_sapi_name() == "cli") ? "php://stdin" : "php://input");
// Decode contents as JSON
$update = json_decode($content, true);
if (!$update) {
error_log('Bad message received (not JSON)');
exit;
}
else {
if (isset($update['message'])) {
process_message($update['message']);
}
else {
error_log('Bad message received (no message field)');
exit;
}
}
?>