fro_oo
fro_oo

Reputation: 1610

How to send/share custom data to FB when a user Like a post on a posts page?

Consider a page with many posts as:

Page A
  - post 1
  - post 2
  - post 3
  - ...

Is it possible to add a Like button for each post (1, 2, 3, ...) and when a user "Like" one of them, send/share the information of that post on Facebook?

For each post I wan to share the title, description, photo, ...

I can't use Open Graph meta data because it's page related, right?

Thank you for you answers, I'm stuck.

Upvotes: 0

Views: 1027

Answers (2)

mrtom
mrtom

Reputation: 2156

Sure, just make the like button URL something like http://www.yourblog.com/pages/A?title=post1&description=blah&image=baz.png

Then in your site/blog you need to take the query data from the URL and add that into your meta data dynamically*, i.e.

<meta type="og:title" content={GET['title']} />
<meta type="og:description" content={GET['description']} />
<meta type="og:image" content={GET['image']} /> 

(this is pseudo code)

*Technically you only need to do this when the User Agent is the Facebook scraper, but you may as well do it always unless there's a strong reason not to. See https://developers.facebook.com/docs/opengraphprotocol/ for more information.

Upvotes: 1

cpilko
cpilko

Reputation: 11852

As long as each post has its own unique URL with Facebook metadata on it, yes you can.

Each like button has to have a reference to the respective page.

Upvotes: 1

Related Questions