Is there a simple Facebook "Like" or share URL?
Asked Answered
C

5

7

Is there a simple URL string that Facebook will accept to "like" a site... or more accurately (as a commenter points out below), share a site? As a comparison, Twitter allows you to post from any page simply by pointing an anchor at a customized URL... like this:

<a href="https://twitter.com/share?text=Check%20out%20this%20site:&url=http://example.com">Tweet this!</a>

I can't seem to find anything in the Facebook documentation.

Cruzcruzado answered 24/1, 2012 at 15:3 Comment(3)
I don't think so. You need to interact with the graph api. Here's the docs developers.facebook.com/docs/reference/plugins/likeElegist
You say "Like" but I think you mean "Share". Facebook treats these differently.Lora
@AdamHarte you're right, I do mean share. This thread is more than two years old now, so I'm not sure if it would be more confusing to edit it now...Cruzcruzado
C
12

Not exactly an answer, but close enough for me:

http://www.facebook.com/sharer.php?u=http://mysite.com/

That'll do it.

Cruzcruzado answered 24/1, 2012 at 20:0 Comment(3)
sharer.php is deprecate and should not be used. It is not supported by Facebook and can stop working at any time when they pull the plug on its life supportIleostomy
Commens are unfair. It works, he never said that it is the best most accepted solution.Mogul
Looks like they changed their mind about deprecating it. The sharer.php url is a fine solution: developers.facebook.com/docs/reference/plugins/share-linksDunleavy
M
4

There is a non-depreciated equivalent to the twitter or sharer.php functionality, though it is way more annoying. This doesn't exactly answer the question about "liking" a page but does accomplish the exact analogy to the twitter share, which seems to be what the question is asking.

  • https://developers.facebook.com/apps/ - make a new app with a developer account.
  • Make the Display Name the name of your business or website
  • add your domain without http under App Domains
  • add your base URL under Website with Facebook Login (with http )
  • Grab the App ID

Now make your url like this:

http://www.facebook.com/dialog/feed?app_id=000000000000000&link=http://example.com/whatever&redirect_uri=http://example.com/backtothesite

You would think the redirect_uri would default to the user's facebook home or to the link parameter, but it's a required field.

More parameters here: http://developers.facebook.com/docs/reference/dialogs/feed/

Magnesite answered 27/9, 2012 at 6:40 Comment(1)
See jeremysawesome's comment above - looks like sharer.php link is no longer being depreciated. I'm now using either that or my answer above depending on the context.Magnesite
F
3

No, Facebook only permits Liking a page via a Like button.

Florey answered 24/1, 2012 at 15:5 Comment(0)
U
1

There is a way how to do it, but not very comfortable for users, because they must click on 'like' button twice.

https://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fexample.com%2F

http%3A%2F%2Fexample.com%2F is url encoded version of http://example.com/ .

Or you can place this link into iframe and then only one click is needed for liking of url

Upraise answered 19/9, 2014 at 12:27 Comment(0)
I
-3

It's a little more verbose with Facebook to do the same thing.

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId={YOUR_APP_ID}";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like" 
    data-href="http://mysite.com" 
    data-send="true" 
    data-width="450" 
    data-show-faces="true">
</div>
Ileostomy answered 24/1, 2012 at 15:12 Comment(6)
This inserts an iframe into your page- it's not a URL you can point to with an a-element.Neumark
Correct, but it is the approved Facebook way of liking. Please read their documentation.Ileostomy
We've all read their documentation ... the whole point of this question is whether there's a way to implement a "like" link without submitting to Facebook's crap iframe implementation.Neumark
The answer is No, facebook no longer allows this. The like plugin is their solution for no longer allowing <a links. FWIW, it's clear the whole point of the question was to do a like of a site.Ileostomy
I quote: "Is there a simple URL string that Facebook will accept to "like" a site?". This would allow styling the "like" button instead of having to settle for one of three canned styles; and also supporting "like" on older phones, or for users that have Javascript switched off.Neumark
The answer is still No, please use the one Facebook says to use.Ileostomy

© 2022 - 2024 — McMap. All rights reserved.