Created
July 31, 2017 18:21
-
-
Save salvatorecordiano/1a7864bab29d0d6e170493babaca5d26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$chatId = '---YOUR USER ID---'; | |
$request = [ | |
'chat_id' => $chatId, | |
'text' => 'Fai tap su condividi numero telefonico', | |
'reply_markup' => [ | |
'keyboard' => [ | |
[ | |
[ | |
'text' => 'Condividi numero telefonico', | |
'request_contact' => true | |
] | |
] | |
], | |
'one_time_keyboard' => true, | |
'resize_keyboard' => true | |
] | |
]; | |
apiRequest('---INSERT API TOKEN HERE---', $request); | |
function apiRequest(string $apiToken, array $request): array | |
{ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, sprintf('https://api.telegram.org/bot%s/sendMessage', $apiToken)); | |
curl_setopt($ch, CURLOPT_POST, true); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-type: application/json']); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request)); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$content = curl_exec($ch); | |
curl_close($ch); | |
if(!$content) { | |
return []; | |
} | |
return json_decode($content, true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ciao, non sono per nulla nerd ma per un problema di update del mio iPhone mi ritrovo ad aver perso una conversazione Telegram e soprattutto il numero della persona.. l’iphone Mi ha salvato solo il suo ID... posso recuperare il suo numero con il
solo ID? Grazie ho provato a chiedere all’assustenza Telegram ma non rispondono...