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).
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?
Thanks in advance!
5
Answers
OK, so here's the deal:
The URL is to an Amazon S3 bucket (like I said in the question). It turns out that the Facebook server wasn't able to validate the SSL certificate for the S3 bucket. I don't know why it worked on the web version, but that's what Facebook support said.
Anyway, after searching online I found that the URL to an S3 bucket may cause problems with SSL certificates if there are dots (".") in the bucket name (see http://shlomoswidler.com/2009/08/amazon-s3-gotcha-using-virtual-host.html). And I did name it with dots.
I renamed the bucket and everything's fine. So remember: don't name your S3 buckets with something like my.new.bucket.
Yariv.
I think the structured message templates are not working on iOS right now. (at least not for me)
I had the same image loading issue on mobile applications. I found out the problematic image file names had whitespaces in it. Try replacing the spaces with ‘-‘ or ‘_’ and check.
This happens in iOS Messenger app when there is no subdomain in the URL of the image.
In my case, I change from https://example.com/image.jpg
to https://mysub.example.com/image.jpg and the problem is solved.
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.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:
Make sure my image could be accessed at
http://example.org/image.png
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.