Solved

How to add a dynamic facebook like button in ASP

Posted on 2010-09-23
13
972 Views
Last Modified: 2012-05-10
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?
0
Comment
Question by:freezilla
  • 8
  • 4
13 Comments
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 33748819
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

0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 33748840
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
0
 

Author Comment

by:freezilla
ID: 33749358
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.
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 33749446
It should work out of the box.
Good Luck
Carrzkiss
0
 
LVL 16

Expert Comment

by:golfDoctor
ID: 33749521
For dynamic site, you simply add the URL to the embed tag:

<iframe src=""http://www.facebook.com/plugins/like.php?href=YOUR_URL&amp;layout=button_count&amp;show_faces=false&amp;width=80&amp;action=like&amp;font=lucida+grande&amp;colorscheme=light"" scrolling=""no"" frameborder=""0"" allowTransparency=""true"" style=""border:none; overflow:hidden; width:80px; height:21px;margin-top:5px;""></iframe>
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 33749883
golfDoctor, did you not see that I already provided this to him?
http:#a33748819
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:freezilla
ID: 33753812
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?
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 33754570
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.
0
 
LVL 30

Accepted Solution

by:
Wayne Barron earned 500 total points
ID: 33755539
Let me better explain this to you.
Break down the code.

http://www.yourdomain.com/Main.asp?"&(Request.QueryString))%>

In the above URL, change the    domain.com   to yours
The Main.asp change this to your page.  review.asp
The ?"&(Request.QueryString))%>
Leave this alone, this will grab your Querystring which is ?reviewid=1234

Now, that is all that needs to be done to this for it to work on your site.

So yours string will look like this.
(Changing to fit your example that you provided above)

http://www.sitename.com/reviews.asp?"&(Request.QueryString))%>

And the code below will work in your page.
Just change the    sitename.com to your actual domain name.
That is all the needs to be changed for it to work.

Good Luck
Carrzkiss
Facebook LIKE



<iframe src="http://www.facebook.com/plugins/like.php?href=<%=EncodeURL("http://www.sitename.com/reviews.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

0
 

Author Comment

by:freezilla
ID: 33756544
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.
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 33757609
what did not work?
This is what I use, and it works on my site(s)
0
 

Author Comment

by:freezilla
ID: 33771376
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 />
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 33773095
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

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Read about why website design really matters in today's demanding market.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now