Skip to content

Instantly share code, notes, and snippets.

@salvatorecordiano
Created July 31, 2017 18:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salvatorecordiano/1a7864bab29d0d6e170493babaca5d26 to your computer and use it in GitHub Desktop.
Save salvatorecordiano/1a7864bab29d0d6e170493babaca5d26 to your computer and use it in GitHub Desktop.
<?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);
}
@marcosimone8
Copy link

marcosimone8 commented May 8, 2020

Ho provato ad implementare un bot che richieda il numero di telefono e lo inoltri direttamente in un'altra chat (in alternativa sarebbe utile salvarlo in un file di testo, ma non ci sono riuscito). Qual è il problema? Purtroppo conosco C e un po' di Java, ma non sono molto pratico con php...

codcie

@saretta2480
Copy link

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment