Skip to main content

Facebook share links - controlling the data sent

An article from ComputerMinds - Building with Drupal in the UK since 2005
22nd Apr 2011

Mike Dixon

Senior Mind
Hey, you seem to look at this article a lot! Why not Bookmark this article so you can find it easily in the future?

Not strictly a Drupal post this, but something that I was playing with yesterday that I was really struggling to find any documentation on. We wanted a simple "share" on facebook link, we didn't want to go through the process of creating an app and using the opengraph API - instead we just want to use the simple sharer.php script but have a bit of control over what is being shared.

The basic approach is you are providing a link to http://www.facebook.com/sharer.php?s=100 which is the basic share page (typically this is shown in a popup).

By adding querystring params we can set a title, link and summary on the shared post - like so


&p[title] = Mike loves ComputerMinds
&p[url] = http://www.computerminds.co.uk
&p[summary] = Mike really really loves ComputerMinds

The final point is that those values MUST be URL encoded - just using the url_encode will do the job - which would leave something like this


http://www.facebook.com/sharer.php?s=100&p[title]=
Mike+loves+ComputerMinds&p[url]=
http%3A%2F%2Fwww.computerminds.co.uk&p[summary]=Mike+really+really+loves+ComputerMinds

Which we can then turn into a nice link - Share on FaceBook

Hi, thanks for reading

ComputerMinds are the UK’s Drupal specialists with offices in Bristol and Coventry. We offer a range of Drupal services including Consultancy, Development, Training and Support. Whatever your Drupal problem, we can help.