How to make a Facebook "Like" button that is just a link, not an iFrame?
Asked Answered
P

4

24

I would like to put a "Like" button into an email message that it going out to our e-newsletter subscribers. The usual way of embedding a Like button, which uses, an iframe technique, is not going to work.

What I would like to do is to have a static hyperlink, where clicking on the button image will just go to a particular URL that is our corresponding Facebook page, and do the action of becoming a fan.

Can anybody figured out an official or unofficial kind of URL that one could link to that takes you to the page on Facebook and performs the appropriate action?

Proximity answered 2/6, 2010 at 3:53 Comment(0)
S
7

It would be a horribly insecure system if a link could force the action to happen. People would be 'liking' things all the shop that they didn't want to. Imagine how easy it would be for companies to send out a shortened URL on Twitter and get hundreds of illicit 'likes'.

It's better to let people do that explicitly themselves so from an email the best you can do is to link people to the Facebook page and hope they'll click like. If it's a good/useful page then chances are they will.

One approach is to have the email aimed at getting people to a landing page on your own site. You can then have a like button on that and using the Open Graph Protocol meta tags have that 'like' applied to the home page or whole site.

If you want your like button on the landing page to be a general one for the entire site then use the canonical og:url meta tag eg:

<meta name="og:url" content="http://yoursite.com/" />
Sholom answered 10/12, 2010 at 16:15 Comment(1)
This is a correct answer but sometimes it is difficult to explain it to your boss, if this is your case, you can offer my answer to your management.Babblement
L
7

It was never possible to like some site with Facebook "Like" plugin from email for security reasons. Only if some server administrator does not cut the JS or iframes, but it is not normal – most email servers cut it.

This answer (from Yevgeniy Afanasyev) is absolutely wrong! It was never worked! The code in this answer gives you only the possibility to go to Facebook page and then you have there the possibility to like this site. All this code from this answer doesn't more than give you the link like this:

https://www.facebook.com/plugins/like.php?href=https://stackoverflow.com

In the part href=https://stackoverflow.com from this link you could put any other site adress. If you have in this adress some & character then you have to replace it with &amp;.

And do not think that if this answer was many times upvoted then it is correct or was worked. I think this users which upvoted this unswer do not understand what they have done. They have seen some code and upvoted it without thinking or without understanding.

Why is this not possible

Just imagine you get an email and some link button in it with text "Very funny videos". And then if you click on it then you would like some site which you do not like or do not know. And because of this for security reasons it was never possible.

You have always to confirm all your actions if you use some links.

Possible workaround

Instead of this link you could write some nice landing page for your site and in email you could write this link in email button with adress to this page. And in this page you can use normal Facebook "Like" plugin.

Lorrielorrimer answered 23/11, 2018 at 22:45 Comment(2)
Thank you for your critic to my answer, sorry I did not notice it straight away. Now, when I noticed it I believe I have improved it. In the future, please leave critic as a comment, that is how I'll be notified about your ideas. Thank you.Babblement
The "normal Facebook "Like" plugin" will cost you like 10-20 scores on Page Speed Insights. It's a huge amount of load and processing. So it does come with disadvantages.Buckhound
B
6

It was never possible to like some site with Facebook "Like" plugin from email for security reasons.

But sometimes it is difficult to explain it to your boss, who wants something similar that others emails have. If this was your case, you could offer my answer to your management.

The following code doesn't make you a fan of the page but rather likes the site's home page, and it gives you a Like button and "X people like this. Be the first of your friends."

If this is what you want, please see the code:

replace http://eyeclarity.com.au - to your site and if you do not like my like button, replace http://www.4wdaction.com.au/_phpBB/download/file.php?id=68849 with your one

<a title="Like this on Facebook" 
   href="http://www.facebook.com/plugins/like.php?href=http://eyeclarity.com.au&amp;
   layout=standard&amp;
   show_faces=false&amp;
   width=450&amp;
   action=like&amp;
   colorscheme=light&amp;"
>
    <img title="Facebook Like Button"
         src="https://upload.wikimedia.org/wikipedia/commons/1/13/Facebook_like_thumb.png" 
         alt="" 
         height="50" 
         width="50" 
    />
</a>

jsfiddle

aforementioned code will redirect you to a link, that looks like this

https://www.facebook.com/plugins/like.php?href=http://eyeclarity.com.au&%20%20%20layout=standard&%20%20%20show_faces=false&%20%20%20width=450&%20%20%20action=like&%20%20%20colorscheme=light&

Now, you can try clicking it and see some animation that Facebook is offering.

Babblement answered 24/4, 2013 at 1:9 Comment(3)
This doesn't become a fan of the page but rather likes the site's home page which is very different. Plus the page it renders is quite cryptic; it doesn't even say what URL you're liking, just a Like button and "X people like this. Be the first of your friends."Unarmed
@DavidHarkness Thank you for your comment that does explain what the answer offers. I liked your words so much I put them into the answer itself. Please let me know if you approve it. Thank you.Babblement
@DavidHarkness, I also put a comment to the roborourke's answer saying that his answer is the best, but mine is here just to offer some alternative to the managers that wants something similar that others emails have.Babblement
Z
1

In addition to another answers that says it's impossible, I'll show a brief explanation why it should not be supported by the Facebook(or any other sites that requires login).

Let's suppose someone had a post, and Facebook gave the href that automatically likes the post to the owner. (let's just say fb.com/like/post_id for simplicity's sake)

What happens if he rolls out email newsletters that includes some tag like this?

<img src="fb.com/like/post_id" />

It's not definitely a img src, but web browsers will try to connect to fb.com/like/post_id anyway, and...boom. By reading this email you automatically liked that post regardless of your intention.

This is why it shouldn't be possible to roll out email that includes Like link.

Zounds answered 30/11, 2018 at 3:36 Comment(2)
In accordance to REST specification like button should activate POST request, when <img tag will activate Get requests.Babblement
@YevgeniyAfanasyev Yes, like buttons in form should send POST request, but this question is asking about a link that can be embedded within a email. I imagine when a user clicks a link in the email it changes href.location(or open new one if target='blank') which sends GET request of that URL.Zounds

© 2022 - 2024 — McMap. All rights reserved.