Author image
Senior Mind

Facebook share links - controlling the data sent

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 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] =
&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[title]=Mike+loves+ComputerMinds&p[url][summary]=Mike+really+really+loves+ComputerMinds

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


Oh - and a little bit of jquery will handle the popup nicely - something like

  $('a.fb-share').click(function(ev){$(this).attr('href'), 'sharer','toolbar=0,status=0,width=700,height=436');
    return false;

Lovely stuff :)

Comments on this article are now closed, if you want to give us feeback you can use our contact form instead.