Link to home
Start Free TrialLog in
Avatar of ChilliSauce
ChilliSauceFlag for Afghanistan

asked on

Is it possible to obtainfacebook "Likes" data, to use in an application?

Hi,

This is what I want to do: I have a webstore which contains various products. Against each product I want to add the "facebook like" bookmarking function.

What I then would like to do is allow users to sort products by the number of "likes".

Is this a feasible possibility and if so how would you best acomplish it?

I know that you can add the facebook like function direct, or you could use something like "add this" - would either / both provide a possible solution to do this?

What would your suggestions be?

Thanks
Avatar of gwkg
gwkg
Flag of United States of America image

I think you would have to add a value to the database each time the like button is clicked, using a callback function

FAQ

How do I know when a user clicks a Like button?

If you are using the XFBML version of the button, you can subscribe to the 'edge.create' event through FB.Event.subscribe.

http://developers.facebook.com/docs/reference/plugins/like/
Avatar of ChilliSauce

ASKER

Thanks for the advice.

Can you tell me if it is possible to pass a variable with a button click and get that variable in a call back?

EG suppose I have a variable "ProductID" which I can pass with a button, if I can get that variable back then I can just update the database with a count against that product ID.

Thanks in advance
You can grab anything on the page with javascript: form values, inner html, tag attributes, etc so your callback function could grab it that way.

So if you had

<ul>
  <li>Product Id: <span id="product-id">11134</span></li>
  <li>Price: <span id="product-price">$23.99</span></li>
</ul>

it would be something like

var productid = document.getElementById('product-id').innerHTML

I'm not a javascript expert though.
ASKER CERTIFIED SOLUTION
Avatar of prajapati84
prajapati84
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial