Closed marcelozao closed 3 years ago
hi. check this sample
$option = array(array($telegram->buildKeyboardButton("click to send location!",false,true)));
$keyb = $telegram->buildKeyBoard($option, $onetime=false);
$content = array('chat_id' => $chat_id, 'reply_markup' => $keyb, 'text' => "please send your location via Button...");
$telegram->sendMessage($content);
Great! Work! Thank you ! And where (variables) coordinates send by user, or how recovery ?
your welcome here my full code i wrote and tested before :)) ` include("Telegram.php");
// Set the bot TOKEN date_default_timezone_set("Asia/Tehran");
$bot_id = "Your_Token"; // Instances the class $telegram = new Telegram($bot_id);
// Take text and chat_id from the message $text = $telegram->Text(); $chat_id = $telegram->ChatID();
$type = $telegram->getUpdateType();
if($type=='location'){
$latitude = $telegram->Latitude();
$longitude = $telegram->Longitude();
$content = ['text' => '<b>Latitude:</b> '.$latitude, 'parse_mode' => 'HTML','chat_id' => $chat_id];
$telegram->sendMessage($content);
$content = ['text' => '<b>Longtitude:</b> '.$longitude, 'parse_mode' => 'HTML','chat_id' => $chat_id];
$telegram->sendMessage($content);
}
if($type=='contact'){
$phone = $telegram->getContactPhoneNumber();
$name = $telegram->getContactFirstName();
$content = ['text' => '<b>Phone Number:</b> '.$phone, 'parse_mode' => 'HTML','chat_id' => $chat_id];
$telegram->sendMessage($content);
$content = ['text' => '<b>Contact Name:</b> '.$name, 'parse_mode' => 'HTML','chat_id' => $chat_id];
$telegram->sendMessage($content);
} `
i just forgot one more thing!
these methods doesnt exist in main class. i added these, u can use freely 👍
` /// return latitude public function Latitude() { if ($this->getUpdateType() == "location") return $this->data["message"]["location"]["latitude"]; }
/// return longitude
public function Longitude()
{
if ($this->getUpdateType() == "location")
return $this->data["message"]["location"]["longitude"];
}`
Hum blank latitude and longitude, perhaps I have change getUpdateType() too?
maybe...
Ok, I did: $type = $telegram->getUpdateType(); $content = ['text' => 'Type: '.$type, 'parse_mode' => 'HTML','chat_id' => $chat_id]; $telegram->sendMessage($content);
and after send location or contact the response is: Type: reply
Why reply? Expected contact or location. Whats is wrong?
@Mohsen322 with the same logic, is it possible to get the Live Location longitude/latitude?
Is it possible to send or how can I send 'contact phone' and 'contact location' values by InlineKeyboardButton?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
How use Location function ?