Messenger无法在移动应用程序的通用模板中显示图像 [英] Messenger not displaying images in Generic template in mobile App

查看:186
本文介绍了Messenger无法在移动应用程序的通用模板中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向Facebook发送结构化消息,其中包含指向图像文件的URL(该文件位于Amazon S3中).该消息是根据 https://developers.facebook构建的.com/docs/messenger-platform/send-api-reference/generic-template (通用模板).

I'm sending Facebook a structured message with a URL to an image file (the file is in Amazon S3). The message is structured according to https://developers.facebook.com/docs/messenger-platform/send-api-reference/generic-template (Generic template).

正在接收该消息,并且显示的很好-但该图像未出现在移动iOS Messenger应用中(我没有测试Android).它确实出现在Messenger的网络版本中.

The message is being received and shown just fine - but the image doesn't appear in the mobile iOS Messenger app (I didn't test Android). It DOES appear in the web version of Messenger.

有人知道是什么原因造成的吗?

Anyone know what can cause this?

提前谢谢!

推荐答案

之所以发生这种情况,是因为Facebook通过其URL缓存图像.假设您要在通用模板中的URL http://example.org/image.png上发送图像.

This happens because Facebook caches images by their URL. Let's say you're trying to send an image at URL http://example.org/image.png in your generic template.

当调用Send API时,FB尝试从http://example.org/image.png加载图像.将来在发送同一图像时,FB会使用其缓存版本,而不是从端点重新加载它.如果此端点在第一次发送时未能正确提供图像,则FB将继续缓存/呈现空白图像.

When you make a call to the Send API, FB attempts to loads the image from http://example.org/image.png. When you send the same image in the future FB uses their cached version instead of reloading it from your endpoint. If this endpoint fails to serve the image correctly at the first send, FB will continue to cache / render a blank image.

我遇到了此问题,并通过以下操作对其进行了修复:

I encountered this and fixed it by doing the following:

  1. 确保可以在http://example.org/image.png

在对FB API的调用中为image_url添加URL参数.使用http://example.org/image.png?time=1524606955198

Add a URL parameter for the image_url in your call to FB API. Use http://example.org/image.png?time=1524606955198

希望您的图片开始显示.

Hopefully your image starts showing up.

这篇关于Messenger无法在移动应用程序的通用模板中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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