Let say I have developed a web page with some bar charts that updates once a day. I want to share this web page on social networks like Facebook and Twitter, and when people press a share button they should get an image of the web page (like a screenshot) with the updated bar chart together with some text to share. So every day when the bar charts updates, the shareable image also changes. Is this possible? Is there any "plugins" or "GitHub code" to use? Thanks in advice!
1
votes
You need to provide all that data via Open Graph meta tags, and then re-scrape the URL using the debug tool or the API endpoint provided for that purpose. Asking for recommendations on external resources like plugins is off-topic here though.
– CBroe
Thanks! Ok, I understand regarding recommendations on external resources.
– Simon Johansson
Could you @CBroe please provide a short code example? I know a little about coding but are very much a beginner. I think that anything will help. Thanks in advance!
– Simon Johansson
Would not make much sense, this can’t be explained via a short example. Check these two documents, that should give you all the info you need: developers.facebook.com/docs/sharing/webmasters, developers.facebook.com/docs/sharing/opengraph/…
– CBroe
(Be aware though that this will not automatically update the data in already existing posts that shared your link; those could only be manually refreshed by the sharing user or page themselves.)
– CBroe
1 Answers
1
votes
I recently took this approach leveraging Thum.io for a WordPress site - you may have to modify your code a bit if you're using something other than PHP.
Thum.io offers an on the fly screenshot API, it is a paid for service, here's a little info from them on OG images, too: https://www.thum.io/facebook-twitter-share-screenshots
<meta property="og:image" content="https://image.thum.io/get/auth/YOUR-AUTH-TOKEN/width/1200/crop/630/<?php echo 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>" />