Skip to content

Instantly share code, notes, and snippets.

@salvatorecordiano
Last active June 4, 2017 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salvatorecordiano/eb865b4195fc321f167564e33002f133 to your computer and use it in GitHub Desktop.
Save salvatorecordiano/eb865b4195fc321f167564e33002f133 to your computer and use it in GitHub Desktop.
<?php
$content = file_get_contents("php://input");
$update = json_decode($content, true);
if (! $update) {
exit;
}
$chatId = $update['message']['chat']['id'] ?? null;
if ($channelName = $update['channel_post']['chat']['username'] ?? null) {
$chatId = sprintf('@%s', $channelName);
}
if (! $chatId) {
exit;
}
header('Content-Type: application/json');
$dump = json_encode($update, JSON_PRETTY_PRINT);
echo json_encode(
[
'chat_id' => $chatId,
'text' => "```\n$dump\n```",
'method' => 'sendMessage',
'parse_mode' => 'markdown'
]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment