简体   繁体   English

如何使用 twilio 在 whatsapp 上发送位置 object?

[英]How to send the location object on whatsapp using twilio?

can I send a location using MessagingResponse?我可以使用 MessagingResponse 发送位置信息吗?

when i try the below approach i get AttributeError: 'Message' object has no attribute 'persistent_action'当我尝试以下方法时,我得到 AttributeError: 'Message' object has no attribute 'persistent_action'

from flask import Flask, request
import requests
from twilio.twiml.messaging_response import MessagingResponse

app = Flask(__name__)
@app.route('/bot', methods=['POST'])
def bot():
    resp = MessagingResponse()
    msg = resp.message()
    if request.values.get('Latitude'):
        lat = request.values.get('Latitude')
        long = request.values.get('Longitude')
        location = 'geo:'+lat+','+long
        loc = [location]
        msg.persistent_action(loc)
        return str(resp)
if __name__ == '__main__':
app.run()

It appears based on the documentation, that the only way to send location via WhatsApp, at least currently, is via the REST API.根据文档显示,至少目前通过 WhatsApp 发送位置的唯一方法是通过 REST API。

Location Messages with WhatsApp 使用 WhatsApp 的位置消息

  • See code example: "Send a WhatsApp message with location information"请参阅代码示例:“发送带有位置信息的 WhatsApp 消息”

How To Send Location Details on WhatsApp in Node JS 如何在 Node JS 中发送 WhatsApp 的位置信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM