Eleirbag89 / TelegramBotPHP

A very simple PHP Telegram Bot API for sending messages.
http://eleirbag89.github.io/TelegramBotPHP
MIT License
807 stars 341 forks source link

Live Location #167

Closed FrancescoBOT closed 5 years ago

FrancescoBOT commented 5 years ago

If the user is manually sharing the live position with the bot, How can I receive / read the new position? thank you

swim89 commented 5 years ago

@Eleirbag89 do you know how to solve it?

Eleirbag89 commented 5 years ago

Did you try to check for messages having the property location setted for the user ?

swim89 commented 5 years ago

How can I see that?

Eleirbag89 commented 5 years ago

Check in the webhook if

$telegram->Location();

has a value

swim89 commented 5 years ago

No, it hasn't value. If I check the msg type I have this results: {"type":"edited_message"}

Eleirbag89 commented 5 years ago

Maybe the edited messages contains the updated position ? can you post all the response object ?

swim89 commented 5 years ago

Hi @Eleirbag89 but how can I get the response of a received message?

Eleirbag89 commented 5 years ago

Usually i do

$bot_id = "XXXX";
$telegram = new Telegram($bot_id);
$data = $telegram->getData();
$log = fopen("log.txt", "w");
fwrite($log, $data);
fclose($log);

and then check the file log.txt after the webhook invocation

swim89 commented 5 years ago

Hi @Eleirbag89 this is the response...so how do you suggest to get?

{"update_id":368209607,"edited_message":{"message_id":742,"from":{"id":41*17*33,"is_bot":false,"first_name":"Luca \uf8ff","username":"","language_code":"it"},"chat":{"id":41*17*33,"first_name":"Luca \uf8ff","username":"","type":"private"},"date":1550689346,"edit_date":1550689618,"location":{"latitude":37.540262,"longitude":15.085798}}}

swim89 commented 5 years ago

I found the solution: $data = $telegram->getData(); $position = $data["edited_message"]["location"]; $lat = $position["latitude"]; $lon = $position["longitude"];