We are a small web development and marketing studio.
We are known for being efficient and pragmatic without compromising on quality.

Generate a 'share with facebook' link that embed summary, title, images but without OG Data

ruby,rails,facebook

I’m currently working on the next version of My Drinkaware app, and yesterday my feature card was to share some information on Facebook.

Easy right?

Yes, sharing with Facebook is usually super simple. Either you have the normal ‘Share with Facebook’ link or button, which will retrieve the OpenGraph data from your page, or you have to create your own link containing all those information.

The problem

One of the new features of My Drinkaware is the ability to share what you drink shown as equivalents in food (burgers, kebabs, donuts) or exercises (running, cycling, swimming).

The feature card noticed that I needed to create a small ‘Share with’ button* that would share the user invite link + the contextual equivalence summary + the context equivalence title + the contextual equivalence image (burger, runner…).

Here is en example of the box:

Drinkware Equivalences

And here is what you want to achieve:

Facebook sharing drinkaware

My solution

Obviously, you can go crazy and create a system, which passes the OG data in the url and create them on the page rendering. I’m sure that it would do the job, but it wouldn’t be very efficient.

The Facebook Sharer documentation does not help us a lot here neither (as usual?) as they don’t mention any key parameters that you can pass to your link, that would make it rendering your chosen Summary, Title and Image(s) selection.

In order to to do this, your link must start with the s=100 parameter, then contain a p[title], p[summary] and p[images][x] parameter with the relevant data.

Because I needed to create this kind of link all around the application, I created my own help, which generates the url for you.

So you can now have something along those lines:

Simple, but effective. I hope it can be useful to someone else!

Nathalie mini profile image Post written by Nicolas Alpi

Nicolas is a talented Ruby on Rails/javaScript developer. He manipulates his TypeMatrix keyboard like no one else, likes VIM, Linux, and above all loves finding pragmatic solutions to complex problems. When he is not developing a new web application, he likes reading, hiking and eating Nathalie's cookies.

You can also follow Nicolas on Twitter at @spyou.

If you have any questions contact him at nicolas@wealsodocookies.com or leave a comment.