Facebook’s sharer.php is officially back. Not that most people had stopped using it anyway! Along with the new Share button, you can safely use the sharer.php syntax to create a link that shares a URL on one’s Facebook timeline. As there are still many articles/answers out there that have outdated answers to questions about this, I thought this was worth spreading the news. I’m glad that Facebook’s approach to this no longer has to bring about confusion.
For a while (2012-2013?), the official Facebook docs has a message that the share button was being deprecated. The Like button was to somehow take over. When this message appeared, it started to worry some web developers. Many continued to use the
facebook.com/sharer/sharer.php formatted link (with the correct parameters). There didn’t seem to be a simple replacement, besides the Feed Dialog (API usage + an app ID), and what about the thousands of sites out there already using the Sharer syntax?
With the release of the new Share button in November 2013, the documentation has been updated. There is no longer any mention of deprecation, and the sharer.php method will use the newest version:
This new Share Button works with a new version of our web-based Share Dialog. When using the sharer.php method of invoking the Share Dialog, this dialog will also display the new version without any changes required.
And under their FAQ, it says:
Can I use the Share Dialog without using the Share Button?
Yes, although we recommend using the Share button to offer the simplest and most consistent experience for people using your site, you can invoke the Share Dialog using a link:
New Share Button
The design of the Like and Share button designs have been updated. They can also be easily added side-by-side. Those using existing code for the Like button, should automatically see the new design. More at Facebook:
Update: How to Dynamically Insert the Current Page
Some people commenting on this post were asking about how to have the sharer work with the current page. This can be done by:
- Getting the current page’s URL using PHP
- Using the PHP function urlencode on this URL and printing it after the “u” parameter
The URL encoding is necessary because you are basically sending a URL within a URL, as a parameter in the query string. If you have certain special characters in your URL, then the browser may think it belongs to the facebook.com URL.
Comments on this Article
Do you know how I can update the sharer.php piece of code to pick up the current URL and replace https%3A%2F%2Fparse.com in the code?
You can use PHP to echo the current URL after the “u” parameter in the link, and it should be encoded to be used in a URL. Try this function and then pass the result through the php function urlencode before displaying it.
Hi, as I don’t have much technical skills, can you tell me where to put the Function and how to call it through urlencode function? Thanks
[Second Reply Moved]: Found out how, and it works well, thanks
So, we don’t have the option to determine a custom image via this sharer, as we could?
I guess not. Take a look at this post:
“The sharer will no longer accept custom parameters and facebook will pull the information that is being displayed in the preview the same way that it would appear on facebook as a post from the url OG meta tags.”
Thank you so much, you have solved me a problem I had for three years!
Thanks for the article! A question please: what’s the advantage of facebook.com/sharer/sharer.php over https://www.facebook.com/sharer.php, which is officially used on their website: https://developers.facebook.com/docs/plugins/share-button?
https://www.facebook.com/sharer/sharer.php, so they work the same.
Do you know if its possible to use the share dialog to post directly to fan-page? It seems to only work for the current user’s timeline. I know its easy with the feed dialog but with it being deprecated and all that could pose a problem in the future.
Looks like they changed their FAQ, because I can not find anything mentioned in your post on the FB docs. Guess this is the new approch:
Unfortunately I need to register an app to use this endpoint.
Yeah it looks like the page I was referencing has change dramatically. I wish FB would make up their mind about this. It should still work, but I don’t know what their plans are, and why it was removed from the FAQ.
Thanks, you solved my Problem!
Thank you so much for this post. Made it possible to make a custom share bar. <3
Comments are closed.