Why Is Facebook Share Button Pulling Parameters From The Meta Tags Instead Of My Specified Ones?
Solution 1:
You can create a file on your server that serves a valid HTML file with the correct meta tags.
shared.php?title=Hello&description=FooBar&image=URL&link=LINKURL
<html><head><metaproperty="og:title"value="<?phpecho$_GET['title'] ?>" /><metaproperty="og:description"value="<?phpecho$_GET['description'] ?>" /><metaproperty="og:image"value="<?phpecho$_GET['image'] ?>" ?><scripttype='text/javascript'>setTimeout(function() {
document.location = "<?phpecho$_GET['link'] ?>"; }, 500
);
</script></head></html>
Now just pass this file with the sharer.php, passing all your parameters into this, like so:
<divclass="fb-share-button"data-href="http://YOURSERVER.com/shared.php?title=Hello&description=FooBar&image=URL&link=LINKURL"data-type="button_count"></div>
Or with your original JS code:
<a class='share' onclick="window.open('https://www.facebook.com/sharer/sharer.php?app_id=YOURAPPID&sdk=joey&u=http%3A%2F%2Fyourserver.com%2Fshared.php%3Ftitle%3DHello%26description%3DFooBar%26image%3DURL%26link%3DLINKURL&display=popup', 'newwindow', 'width=555, height=315'); return false;"></a>
When facebook comes crawling your URL, since it passes along the same URL parameters, the same meta tags will be created every time.
A slight delay in the Javascript URL redirect is required to avoid Facebook crawler following through the redirect to the final destination; users clicking on the link in Facebook feed will still get redirected to the final location.
Solution 2:
I was able to find an answer to my solution! I discovered that Facebook released updates in October 2013 to the Feed Dialogue methods the broke the old share codes. Here is an article with recommendations for updating sharing code to the Feed Dialogue method to comply with the October 2013 Breaking Changes: https://developers.facebook.com/docs/reference/dialogs/feed/
I just added extra parameters to the redirection – TITLE & IMAGE (you can see a list of all available parameters at the bottom of that page) and was able to match the look & feel to the old share message. Also had to specify an app ID. Just tested everything and it seems to work again.
https://www.facebook.com/dialog/feed?app_id=145634995501895&display=popup&caption=SUMMARY&link=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fdialogs%2F&redirect_uri=https://developers.facebook.com/tools/explorer&name=TITLE
Post a Comment for "Why Is Facebook Share Button Pulling Parameters From The Meta Tags Instead Of My Specified Ones?"