Rate Limits, Facebook Graph API and Javascript - facebook-graph-api

My search didn't come up with a relevant answer for my problem so I post here hoping to get guidance.
I am developing a not-for-profit website for finding assisted-living solutions.
Each web page has social buttons for sharing/liking in Facebook and it shows the number of shares/likes. We do not require logging for viewing pages.
The problem is that we are constantly hitting the rate limits because of the API calls to get the number of likes (which is important to present) and then the Facebook buttons do not show.
this problem is several months old, probably the limits were changed, or maybe permissions?
All calls are done with the app id.
This is the js that is used when a page loads:
//<!--Start Facebook Script-->
window.fbAsyncInit = function () {
FB.init({
appId: 'my-app-id',
xfbml: true,
version: 'v3.1'
});
};
(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 = 'https://connect.facebook.net/he_IL/sdk.js';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
And the markup for the Facebook buttons is also standard - as suggested by Facebook.
<div style="padding:5px 0; display:inline-block; vertical-align: middle;">
<div class="fb-like" data-layout="button_count" data-href="the-webpage-url" data-action="like" data-size="large" data-show-faces="false" data-share="true" style="display:inline-block;"></div>
</div>
Here are solutions that we have seen but do not wish to use:
We do not want to cache social information
We do not wish to force users to login in order to view the number of likes etc. (Of course they do have to log if they want to actively share or like).
I hope someone can suggest a solution.
Thanks

Related

get Facebook comments of a webpage

I have an app that is connected to my Facebook page.
by using the APP id i have embedded the comments widget to several web pages on my website.
(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/he_IL/sdk.js#xfbml=1&version=v2.8&appId={app_id}";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
I have the facebook comments widget installed on several web pages on my website:
Some pages for example:
<div class="fb-comments" data-href="http://www.foo.bar" data-numposts="20"></div>
<div class="fb-comments" data-href="http://www.foo.bar1" data-numposts="20"></div>
<div class="fb-comments" data-href="http://www.foo.bar2" data-numposts="20"></div>
3. Now im trying to get the comments posted on the pages using facebook graph API
I have tried these and more:
https://graph.facebook.com/http%3A%2F%2Fwww.foo.bar2/comments
https://graph.facebook.com/v2.8/{app_id}/comments
https://graph.facebook.com/{app_id}/comments
Most of them return:
(#100) Tried accessing nonexisting field (comments) on node type (URL)
Is it possible to get the comments posted on a specific webpage ? how ?
Thanks

Like button (Confirm)

I have Facebook Like button but it is not showing in my timeline. When I clicked the like button in my website. It will change to Confirm that once I clicked this, small window will popped up to like that product. In the link of that small window it says something like this
http://www.facebook.com/plugins/error/confirm/like?iframe_referer=http%3A%2F%2F3beacheschemist.doublet.com.au%2Fproductdetail.aspx%3Fname%3DSWISSE-HAND-CREAM-WITH-VIT-F---POMEGRANATE-100ML&secure=false&plugin=like&return_params=%7B%22api_key%22%3A%22171681722971300%22%2C%22locale%22%3A%22en_US%22%2C%22sdk%22%3A%22joey%22%2C%22channel_url%22%3A%22http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D17%23cb%3Dffcb50044%26origin%3Dhttp%253A%252F%252F3beacheschemist.doublet.com.au%252Ff39b47030%26domain%3D3beacheschemist.doublet.com.au%26relation%3Dparent.parent%22%2C%22href%22%3A%22http%3A%2F%2F3beacheschemist.doublet.com.au%2Fproductdetail.aspx%3Fname%3DSWISSE-HAND-CREAM-WITH-VIT-F---POMEGRANATE-100ML%22%2C%22node_type%22%3A%22link%22%2C%22width%22%3A%22450%22%2C%22layout%22%3A%22standard%22%2C%22colorscheme%22%3A%22light%22%2C%22action%22%3A%22recommend%22%2C%22show_faces%22%3A%22false%22%2C%22send%22%3A%22true%22%2C%22extended_social_context%22%3A%22false%22%2C%22ret%22%3A%22sentry%22%2C%22act%22%3A%22connect%22%7D
Before, it is working.All of a sudden I need to change anything which is I don't know.
First, always use the like button generator:
https://developers.facebook.com/docs/reference/plugins/like/
Second, it helps in many cases to use the like button with an app id. Usually the spam confirmation does not show up that often if you use an app id for the facebook integration.
Example (fill in the appId):
<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/de_DE/all.js#xfbml=1&appId=xxxxxxx";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
If that does not work, you can only wait, or maybe it helps to refresh the liked URL in the Facebook debugger:
https://developers.facebook.com/tools/debug

Facebook Comment Box disappear when using it with Backbone.js

I am trying to embedded Facebook comment boxes dynamically generated by Backbone.js in my HTML I have the following code right after the body in my HTML file.
<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=147738045314917";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
Then I dynamically generate the div tags using Backbone template. I embed the following html tag.
<div class="fb-comments" data-href="http://something.com" data-num-posts="2" data-width="470"></div>
The problem is that the comment box don't always show for some reason. I am also using the Facebook SDK in this page too.
I don't really get this, any help would be great. Thank a lot!
After adding new XFBML elements to the DOM (or the HTML5 equivalent in this case), you want to call FB.XFBML.parse on the containing element in order to transform these.

Closing modal pop-up after user clicks "Like"

Our site pops up a modal javascript/jquery dialog, which requires the user to either close or "Like" on facebook to proceed. We are using the HTML5 version of the "Like" code.
The "Close" works fine, but how do I get the dialog to close when the user clicks on "Like"?
The actual "Like" button is provided by Facebook in an IFrame, and I haven't been able to get to it via JavaScript yet.
Any ideas?
Subscribe to the edge.create FB JS event (http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/) and close your popup once you receive that. However, you will run into issues because after a like, Facebook also likes to put up a dialog that allows the liker to post a link to their wall about it. So you might accidentally hide that one by closing your dialog too early.
First of all check that the following code implemented:
<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_GB/all.js#xfbml=1&appId=261463080590982";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
Then just do the following:
<script>
FB.Event.subscribe('edge.create', function(response) {
close_function()
});
</script>
Where close_funciton() is the same function what you call in normal close.
More information about this feature: https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/
If you have more like button in same page with different "function", that's fun.
If you don't want to show it at all
you can use the CSS code below
.fb_edge_widget_with_comment{
position: absolute;
}
.fb_edge_widget_with_comment span.fb_edge_comment_widget iframe.fb_ltr {
display: none !important;
}
Hope it helps :)

Any reason my Facebook Like button pops out a Comment Box? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Any reason my Facebook LIKE used to display a normal BOX and NOW …it shows transparent?
I'm not sure if I have this right, but I intended to add a "LIKE" button
where the user will simply like the site and that's it.
As soon as you click on the LIKE button, it seems to display a Comment box
and anything you type displays on your wall. Even if you don't type anything,
you get the Wall entry.
Anyone can highlight what am I doing wrong here?
I added this on the BODY
<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=xxxxxxxxxxx";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
</script>
and this on the actual button location
<div style="padding-top: 8px;" class="fb-like" data-href="http://www.WinePassionate.com"
data-send="false" data-layout="button_count" data-width="50" data-show-faces="false"
data-font="verdana">
</div>
This is a feature of the Facebook like button that you can't turn off. There is a slight work around if you want. This is taken from their FAQ:
When will users have the option to add a comment to the like?
If you are using the XFBML version of the Like button, users will always have the option to add a comment. If you are using the Iframe version of the button, users will have the option to comments if you are using the 'standard' layout with a width of at least 400 pixels. If users do add a comment, the story published back to Facebook is given more prominence.
So basically it means that you can if you switch to iframe and make it less than 400px wide or iframe and change the layout to something other than standard.