How to make a Facebook “Like” button that is just a link, not an iFrame?

后端 未结 4 1254
独厮守ぢ
独厮守ぢ 2021-01-07 17:48

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 ifram

相关标签:
4条回答
  • 2021-01-07 18:14

    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.

    0 讨论(0)
  • 2021-01-07 18:29

    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/" />
    
    0 讨论(0)
  • 2021-01-07 18:32

    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.

    0 讨论(0)
  • 2021-01-07 18:36

    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.

    0 讨论(0)
提交回复
热议问题