问题
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.
回答1:
Not exactly an answer, but close enough for me:
http://www.facebook.com/sharer.php?u=http://mysite.com/
That'll do it.
回答2:
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/
回答3:
No, Facebook only permits Liking a page via a Like button.
回答4:
At the bottom of this page:
http://developers.facebook.com/docs/share/
Feel free to create your own implementation based on this.
回答5:
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
回答6:
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>
来源:https://stackoverflow.com/questions/8989031/is-there-a-simple-facebook-like-or-share-url