Is it possible to use one application for several likes? - facebook

I have a photoalbum where I'd like to allow several photos to be liked by facebook users.
For example, I have a photoalbum, there are 5 photos. I would like something like this:
a.jpg (12 people like it)
b.jpg (23 people like it)
c.jpg (3 people like it)
Is possible to do with single registred application?

There are a few ways to do this depending on your application.
If you do not authenticate users in your app, then you have generate URLs for each image and then insert like buttons for each image. For example, you can create a page in your app called photo.php which takes an ID and displays that image. You can then add like buttons for each image with the URL set to the photo URL in your app:
<div class="fb-like"
data-href="http://apps.facebook.com/myapplication/photo.php?id=1"
data-layout="button_count" data-action="like" data-show-faces="false"
data-share="false">
</div>
<div class="fb-like"
data-href="http://apps.facebook.com/myapplication/photo.php?id=2"
data-layout="button_count" data-action="like" data-show-faces="false"
data-share="false">
</div>
<div class="fb-like"
data-href="http://apps.facebook.com/myapplication/photo.php?id=3"
data-layout="button_count" data-action="like" data-show-faces="false"
data-share="false">
</div>
If the images are within a Facebook photo album, then the likes that you get via these buttons will not count towards the likes the photos get in the Facebook photo album. Also, if you want nice details to be displayed in the users timeline for each of the likes then you should be sure to include the relevant Open Graph meta tags on the photo.php page. You can dynamically generate these from the photo ID. Without authentication, there is no way to generate a Facebook like button for a Facebook object such as a photo.
If you are authenticating users, then you can do it differently - you can make it so that the likes that are received in the application actually count towards the likes that the photos have in the Facebook photo album. You will need the "publish_actions" permission as well as "publish_stream". With jQuery you can bind an event similar to below to your own custom like button:
$('#LikePhoto1').click(function(){
$.ajax({
type: 'POST',
url: 'https://graph.facebook.com/PHOTO_OBJECT_ID/likes?method=POST&format=json&access_token=ACCESS_TOKEN',
success: function(res) {
alert('liked');
}
});
});
You will need to find the PHOTO_OBJECT_ID which relates to that photo within that album - I recommend using the Graph API Explorer to do this. Also, you will need to set the ACCESS_TOKEN in the URL to the current authenticated user's access token.
Because this is a custom like button, it doesn't display the number of likes etc - you will need to query this from the Graph API using the URL https://graph.facebook.com/PHOTO_OBJECT_ID/likes?access_token=ACCESS_TOKEN

Related

Facebook like button for facebook single post

I want to add facebook like buttons on my website - they should add likes to some posts on my facebook page. The trouble is that though I set a post URL in href, buttons applies to the page, not the post and likes counter shows total likes for page, and not that single post.
<div class="fb-post" data-href="https://www.facebook.com/eightblackdots/posts/837235539689618/" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>
What am I missing?
It´s not 100% clear in the docs, but you can only use the Like Button for an external URL or a Facebook Page, but not for single posts or anything else on Facebook.

Likes count doesn't match on website and facebook pages

The following website and Facebook page show different 'Like' number counts. The Facebook page shows 125 'Likes'. The website only shows 18 'Likes'. Why are these numbers not the same? What can we do to make them match?
The like button on your website needs to refer to your facebook page. To do this just change
<div class="fb-like" data-href="http://www.customdocksystems.com" data-send="true" data-width="100" data-show-faces="false" data-colorscheme="dark"></div>
to
<div class="fb-like" data-href="https://www.facebook.com/customdocksystems" data-send="true" data-width="100" data-show-faces="false" data-colorscheme="dark"></div>
and the like button on your website will show the number of likes that your Facebook page has. Furthermore, when a user clicks the like button on your website they will like the Facebook page so you can keep in touch with them through that.
The catch to all this is that when people click the like button on your website after this change, the story that is shared to Facebook will direct users to your Facebook Page instead of your website.
Check out "Can I link the Like button to my Facebook page?" on https://developers.facebook.com/docs/reference/plugins/like/ for more information.

Can Facebook Page and third party website share Likes?

I am trying to get my head around this FB API thing and I wonder if it is possible to share likes between FB page and a website.
For example: I have a website example.com that has a like social plug-in button on it, I also have a FB page(as recommended by FB, not sure why I need one) for example.com.
What happens when the user clicks on like? Is it possible to interconnect these entities so that the likes don't get scattered?
You can change the Facebook like-button to a like-box containing the id of your page.
An example of this would be:
<div
class="fb-like-box"
data-href="http://www.facebook.com/example.comFB" data-width="300"
data-height="300" data-show-faces="true"
data-stream="true" data-header="true">
</div>

Facebook Like Button: how to like an image file url?

I want to have it so the Facebook Like Button API is able to 'Like' and image hosted on a server. EG if it can 'Like' something like: mysite.com/photo1.jpg
Currently, this does not work with the API:
http://developers.facebook.com/docs/reference/plugins/like/
<div class="fb-like" data-href="http://mysite.com/photo1.jpg" data-send="true" data-width="450" data-show-faces="true"></div>
Does anyone know of a work around for this? Or do I need to put each image on an HTML page?
Get the iframe of like button from the below link and in that rewrite
href="http://mysite.com/photo1.jpg"
http://stackoverflow.com/questions/12050786/how-to-add-a-facebook-like-button-to-blogger-blog-post/12055011#12055011
Try this it will work

Why different facebook plugins using the same div id name?

We want to integrate the facebook login button plugin, facebook like button, facebook comments with in one page for different purpose.
But we found that they all using the same div id #fb-root. As we know, one div id should be used only time for one page...
How to solve it?
You only need one fb-root. The like button, login, etc will generate where you put the "like", "login", etc tags.
<div class="fb-like" data-send="true" data-width="450" data-show-faces="true"></div>
"Include the JavaScript SDK on your page once, ideally right after the opening tag."
This contains fb-root
Then, Place the code for your plugin wherever you want the plugin to appear on your page.