PHP: Facebook Like box - Being able to like the current page using dynamic URL

Elitec

New Member
I am new to Facebook and I am trying to add the Facebook like button to my website. From the developer section of Facebook, I got the following code to add the like button:\[code\]<iframe src="http://www.facebook.com/plugins/likebox.php?href=http://www.mysite.com&width=292&colorscheme=light&show_faces=false&stream=false&header=false&height=62" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:292px; height:62px;" allowTransparency="true"></iframe>\[/code\]Now I want to be able to place the like button on each page of my website. For this reason, I think using a static link in the above code will be useless. Hence I have my own function that populates the current page URL (including any variables that might be present in the URL) in a constant called: CURRENT_URL So my revised code for the Like button looks like below:\[code\]<iframe src="http://www.facebook.com/plugins/likebox.php?href=<?php echo CURRENT_URL; ?>&width=292&colorscheme=light&show_faces=false&stream=false&header=false&height=62" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:292px; height:62px;" allowTransparency="true"></iframe>\[/code\]When I use the above revised code in my website, I dont see the Like box. Instead, I see an error page in the Iframe that says: \[code\]The page you requested was not found.You may have clicked an expired link or mistyped the address. Some web addresses are case sensitive.\[/code\]If I do a general \[code\]<?php echo CURRENT_URL; ?\[/code\], it is showing the correct URL. There is no problem with the value of the constant. This makes me feel that the iframe is simply trying to load the website name without parsing the constant value. I just want a code that I can use throughout the website without having to manually change the Like button value for each of the pages of my website.So my question is:How can I make this iframe detect the current page URL (including any variables that I may be passing via the URL) and populate the Like button URL value to the current page URL so that user can like this page. All help is appreciated. Thank you.UPDATE (Solution):I found out that theres a big confusion about all this. There are actually 2 types of Like features. One is a normal Like button and the other is Like box. Here are the links:Like Button:http://developers.facebook.com/docs/reference/plugins/likeLike Box:http://developers.facebook.com/docs/reference/plugins/like-boxUse the Like Button code if you want to be people to like the individual pages of your website. The Like Box asks you for: Facebook Page URL. This means that you CANNOT use it for your users to Like your web pages. (I am still working on understanding about Facebook Page URL and how it works and when it fails)Hope this information helps anyone else going through the same trouble and confusion.
 
Back
Top