Twitter card image only showing after sending to validator

Hi,
We have implemented a bot for discourse that sends a tweet when a new topic is created on our forum. It sends in the form of Twitter Card. It arrives correctly and it’s shown perfectly on the timeline.

The issue is that for most of the tweets, the image is not shown until is passed by the card validator (https://cards-dev.twitter.com/validator )

There are plenty of examples on our timeline (TheCháchara (@thechacharaforo) | Twitter) just look for any tweet card with out logo:
image

And use the underlying URL on the validator:

And now, after I’ve ping’d the validator, the timeline shows correctly: TheCháchara on Twitter: "https://t.co/MSEj7IeJnF" (Sorry I can’t post more than 2 images.)

Is there a way to do this automatically?
Furthermore: Why is this happening?

TiA.


Ps: This topic was also open on Twitter Developers Forum, but still no luck :pensive:

I suspect the issue is that we add the topic image metadata in a background job, which runs a few seconds after a topic is created (depending on the load of your forum). If twitter fetches and caches the metadata before we’ve generated the metadata, then it will be caching the old information.

When you run it through their testing tool, it resets their cache, and so it starts working.

To work around it, could you add a delay to your bot? 1-2 minutes should be pretty safe.

4 Likes

AWESOME!

Thanks for the tip @david. I’ll implement it right now, and will let you know.

[EDIT]
It worked like a charm!
giphy

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.