XF 2.1 Trigger external script when thread is posted?

adamgreenough

Well-known member
Hi, I have created a script that generates custom images for Twitter cards and OpenGraph for each thread (with title overlayed etc...)

How can I ping this script with the ID in the URL each time a thread is posted in order to generate these images?

Perhaps if it could be done when edited also would help.
 
can't help you with the callback, but very interested to see how this script works. how do you end up embedding it into the thread metadata?

edit: depending on how dynamic the script is, you could hardcode it into the meta data.

<meta property="og:image" content="http://yourdomain.com/myscript.php?threadid=XXX" />

and return the image live. you'd prob want to cache it so it doesn't kill your server
 
Thank you, yeah that was one option a direct image file would have been preferable that can be generated by the script but may settle for that for now!

The script uses PHP GD to overlay the users avatar, thread title and some other info over a template to provide a more engaging and informative social card image fetched from the API. Will share some more when I got it all working! 😬
 
Got it working your way with some decent caching all is well. I suppose it has the advantage of not creating the image unless something actually requests it!

Demo:

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.
 
Not sure if you kept at this but I finally got around to implementing this:

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.

External php script which pulls the thread title and info and creates a share image.
 
  • Like
Reactions: sbj
Back
Top Bottom