Link to home
Start Free TrialLog in
Avatar of freezilla
freezilla

asked on

How to add a dynamic facebook like button in ASP

Hi there, I've got a DVD/Blu-Ray review web site and want to add Facebook's "Like" button on all my reviews.  Now I can easily do this the static way, but I'm using ASP and a MYSQL database and would like to try and find a way to automate it.  But...I've no idea how.

I was wondering if anyone had taken a crack at this and if so, what the code might be?
Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

I think this is all that you need.
This is what I use on my site(s) and it works like a charm...

Good Luck with the site, I have a similar review site as well that I really need to get back to work on and make it look better, as I threw it together to quickly at the time. Would love to see yours, you can contact me through my email on my profile.

Here is the code that I use.

Information for Facebook SHARE
Change the information that I have marked as CHANGE.....

The <%=CHANGE_TITLE%> this would be for your title of your DVD item.
The other 2 CHANGE are your site name, you can customize this however you need to get it to work for you.

Information for Facebook LIKE

Change the www.yourdomain.com/Main.asp , to your actual domain.com name, that is all that needs to be changed in the LIKE.

Good luck and look forward to see you site if you decide, maybe we can throw some idea's to each other...

Have a good one.
Carrzkiss
Facebook SHARE

<a href="javascript:void(window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(document.location.toString()),'ptm','height=450,width=440').focus())" title="Share With Facebook - CHANGE - <%=CHANGE_TITLE%>"><img src="graph/share/facebook.gif" border="0" alt="CHANGE - Share With Facebook" /></a>

Facebook LIKE

<iframe src="http://www.facebook.com/plugins/like.php?href=<%=EncodeURL("http://www.yourdomain.com/Main.asp?"&(Request.QueryString))%>&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:250px; height:35px;" allowTransparency="true"></iframe>

Open in new window

One last thing.
Save the codes above to a page called: facebook.asp
The in your main page, add it to the page, maybe at the top of a bar or whereever.
<!--#include file="facebook.asp"-->

It only needs to be put in one place to work across your entire site.

Good Luck
Carrzkiss
Avatar of freezilla
freezilla

ASKER

I'll give it a shot and see if it works for me.  I've actually had the site since 1999, but I'm just now incorporating Facebook functionality in there.
It should work out of the box.
Good Luck
Carrzkiss
For dynamic site, you simply add the URL to the embed tag:

<iframe src=""http://www.facebook.com/plugins/like.php?href=YOUR_URL&layout=button_count&show_faces=false&width=80&action=like&font=lucida+grande&colorscheme=light"" scrolling=""no"" frameborder=""0"" allowTransparency=""true"" style=""border:none; overflow:hidden; width:80px; height:21px;margin-top:5px;""></iframe>
golfDoctor, did you not see that I already provided this to him?
http:#a33748819
Hmmm, ok I seem to be a bit lost here.  I’ll try to explain it a bit better.  I’ve got one ASP page that handles all of my reviews and it’s cleverly called “reviews.asp”.  This page pulls all the information from the database and displays it in a query string (which is my URL).  So all I do is go into my admin, enter a review and it spits out the review by the ID number.

For example: www.sitename.com/reviews.asp?reviewid=1234 

So taking this into consideration, how would I use the above code to dynamically generate this link?  Or will I need to add another field to my database called “Facebook” and then manually enter in something when doing a new review?
The code the I provided for you, I have put in a single place on my page.
It works across 10,000+ pages that will grow to be over 1,000,000+ pages by the summer.

Please, follow the instructions that I gave you on what needs to be edited, and it will work for you without any problems, as it works for me.
ASKER CERTIFIED SOLUTION
Avatar of Wayne Barron
Wayne Barron
Flag of United States of America 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
Hmmm, this didn’t work.  Ah well, not that big of a deal, it wasn’t really a necessity for the site.  I appreciate all the help.
what did not work?
This is what I use, and it works on my site(s)
I finally did figure this out.  Here's the code I'm using if it matters...

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.sitename.com%2Freviews.asp%3Freviewid%3D<% =strreviewid %>&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=dark&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="false"></iframe>
<fb:like href="http://www.sitename.com/reviews.asp?reviewid=<% =strreviewid %>" show_faces="false"></fb:like><br />
Give me a little hint.
Always put your code in the code view, so it is better readable.

And glad that you got it figured out.
Take Care and have a good one.
Carrzkiss
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.sitename.com%2Freviews.asp%3Freviewid%3D<%=strreviewid%>&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=dark&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="false"></iframe>
<fb:like href="http://www.sitename.com/reviews.asp?reviewid=<%=strreviewid%>" show_faces="false"></fb:like><br />

Open in new window