-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathhook.php
More file actions
34 lines (30 loc) · 923 Bytes
/
hook.php
File metadata and controls
34 lines (30 loc) · 923 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
<?php
/*
* Telegram Bot Sample
* ===================
* UWiClab, University of Urbino
* ===================
* Basic message processing webhook end-point for your bot.
* Start editing here. =)
*/
include 'lib.php';
// Get input contents
// Notice: we use php://input (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(is_cli() ? "php://stdin" : "php://input");
// Decode contents as JSON
$update = json_decode($content, true);
if (!$update) {
Logger::fatal('Bad message received (not JSON)', __FILE__);
}
else {
if (isset($update['message'])) {
$message = $update['message'];
include 'msg_processing_simple.php';
}
else {
Logger::fatal('Bad message received (no message field)', __FILE__);
}
}
?>