• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

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
0
ChilliSauce
Asked:
ChilliSauce
  • 2
1 Solution
 
gwkgCommented:
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/
0
 
ChilliSauceAuthor Commented:
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
0
 
gwkgCommented:
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.
0
 
prajapati84Commented:
step1: you will require to add a column in database to count likes.
step2: add javascript function to insert like count in database
e.g. <span onclick='updatelike(productid)'>Like</span>
step3: function updatelike(productid) { // async call to execute handler
//here call a http handler and pass productid as querystring
//and you can write insert code on that handler, it will add to db
//e.g. updatelikecount.ashx?productid=yourproductid
step4:get the list of product from database and sort it by likes.

Let me know if you have any difficulty.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now