如何从Facebook Messenger平台发送位置? [英] How to send location from Facebook messenger platform?

查看:234
本文介绍了如何从Facebook Messenger平台发送位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一种方法可以从移动客户端将我的位置发送到facebook-messenger,但是如何从漫游器中发送一些位置呢? (信使平台api)

There is a way to send my location to facebook-messenger from a mobile client, but how can I send some location from a bot? (messenger platform api)

当我尝试从bot发送类似的结构时,出现错误: (#100) Unsupported attachment type

When I try to send a similar structure from bot, I get an error: (#100) Unsupported attachment type

是否可以通过机器人发送我的位置信息?

Is there a way to send my location from bot?

收到的发送给漫游器的消息的示例:

Example of received message to bot:

{
   "object": "page",
   "entry": [{
       "id": "1719442148306048",
       "time": 1466780344978,
       "messaging": [{
           "sender": {"id": "123456789"},
           "recipient": {"id": "987654321"},
           "timestamp": 1466780344847,
           "message": {
               "mid": "mid.12345698875:c80066d69b6cee1779",
               "seq": 65,
               "attachments": [{
                   "title": "Dmitry's Location",
                   "url": "Link to bing.com through facebook redirect"
                   "type": "location",
                   "payload": {"coordinates": {"lat": 55, "long": 37}}
               }]
           }
       }]
   }]
}

我尝试发送带有附件的消息,

I try send message with attachment like this:

               "attachment": {
                   "type": "location",
                   "payload": {"coordinates": {"lat": 55, "long": 37}}
               }

推荐答案

有解决方法. 我们可以将带有静态地图图像和url的通用模板发送给动态模板. 对于iOS本机地图应用程序,我们可以使用地址 http://maps.apple.com/maps (该地址重定向所有非iOS用户使用相同的参数访问Google Maps).在Android上,它将打开Goog​​le Maps应用.

There is workaround. We can send generic template with static map image and url to dynamic. For iOS native map app we can use address http://maps.apple.com/maps (which redirects all non iOS users to Google Maps with the same parameters). On Android it opens Google Maps app.

{
    "recipient": {"id": "132456"},
    "message": {
        "attachment": {
            "type": "template",
            "payload": {
                "template_type": "generic",
                "elements": {
                    "element": {
                        "title": "Your current location",
                        "image_url": "https:\/\/maps.googleapis.com\/maps\/api\/staticmap?size=764x400&center="+lat+","+long+"&zoom=25&markers="+lat+","+long,
                        "item_url": "http:\/\/maps.apple.com\/maps?q="+lat+","+long+"&z=16"
                    }
                }
            }
        }
    }
}

这篇关于如何从Facebook Messenger平台发送位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆