Patrioticcow
Patrioticcow

Reputation: 27058

facebook and PHP. How to add unique like buttons?

I have a table list of products generated in PHP.

The list contains: title | description | price | like_button

the Like button that I use is:

<iframe src="http://www.facebook.com/plugins/like.php?app_id=103750869718158&amp;href= echo "http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"].'; &amp;send=false&amp;layout=button_count&amp;width=100&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>

The list gets generated with, lets say 20 products and respectively 20 likes.

The problem occurs when I click on one Like button, all other like buttons get activated and I would like them to be independent one from each other.

here is an idea

All help or ideas are appreciated, Thanks

Upvotes: 0

Views: 782

Answers (3)

Melisande Buitenkamp
Melisande Buitenkamp

Reputation: 46

did you check this?

facebook developers forum post

Upvotes: 0

David
David

Reputation: 219047

Take a look at the page you're using as an example (not a marketing video of the page, but the actual page itself):

<fb:like width="90" layout="button_count" href="http://r.levi.com/product/index.jsp?productId=3672714&amp;r=&amp;c=3" font="arial" ref="FamilyLike:3515596"></fb:like>

I'm not up to date on Facebook's FBML (XFBML?) markup syntax, but it looks like the key here is the href which is unique per product. That ref attribute also appears to be useful.

According to Facebook:

  • href - the URL to like. The XFBML version defaults to the current page.
  • ref - a label for tracking referrals; must be less than 50 characters and can contain alphanumeric characters and some punctuation (currently +/=-.:_). The ref attribute causes two parameters to be added to the referrer URL when a user clicks a link from a stream story about a Like action:
    • fb_ref - the ref parameter
    • fb_source - the stream type ('home', 'profile', 'search', 'other') in which the click occurred and the story type ('oneline' or 'multiline'), concatenated with an underscore.

I think the biggest difference to notice here is that the desired functionality is implemented using the Facebook markup and JavaScript SDK, as opposed to the simpler iframe method. The additional functionality requires a bit of additional development work, though not much.

Upvotes: 2

ldg
ldg

Reputation: 9402

The HREF attribute needs to be unique for each "like".

Upvotes: 1

Related Questions