Need to save latitude and longitude send via whatsapp location in twilio

与世无争的帅哥 提交于 2020-03-28 06:40:24

问题


I need to save/ show latitude and longitude send via Whatsapp location in Twilio. Right now i am able to store text messages but unable to read WhatsApp location


回答1:


I don't know exactly for Python but in Node.js if a "Location" is attached to a Whatsapp message, it will be present in the POST request parameters and you can get its properties similarly with how you get the body of the message.

If you get the message with req.body.Body then if a location is attached you'll have available as strings

  • req.body.Latitude
  • req.body.Longitude
  • req.body.Address

otherwise they'll be "undefined".

In the request body they look something like this:

[Object: null prototype] {
  Latitude: '37.389958280680645',
  Longitude: '-122.08166124764976',
  Address: '500 Castro St, Mountain View, CA 94041',
  Label: 'Bean Scene Cafe'
  ...
}

Again, I have not tried in Python but maybe is something like this:

message_latitude = request.values.get('Latitude', None)
message_longitude = request.values.get('Longitude', None)
message_address = request.values.get('Address', None)



回答2:


There is a recent blog post announcing this capability, https://www.twilio.com/blog/new-rich-features-support-deeper-customer-engagement-twilio-api-whatsapp.

The blog references this documentation for more details on implementation.

https://www.twilio.com/docs/sms/whatsapp/api#send-a-location-message-with-whatsapp



来源:https://stackoverflow.com/questions/59731901/need-to-save-latitude-and-longitude-send-via-whatsapp-location-in-twilio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!