FB Async Feed failing on Authentication - facebook

The code below has been used for several month successfully. But recently, it stopped working. The objective is to pull the latest feed from a facebook page. The response is now "An access token is required to request this resource." But reading the JS SDK docs never suggest anything more than an app ID for this method. What is the real error here?
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({appId: '<?php echo $this->appId; ?>', status: true, cookie: true, xfbml: true});
FB.api('/<?php echo $this->appId; ?>/feed', {'limit': <?php echo (int)$this->feedLimit; ?>}, function(response) {
if(response.data[0]) {
jQuery('.facebook .comment p a').append(response.data[0].message);
}
});
};
(function() {
var e = document.createElement('script');
e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());

Ah, that should work (if your app ID is indeed correct): did the app ID somehow change to a user ID in the recent past?
EDIT: ah, must be a recent change in the platform. I'm guessing accessing app feeds now need a token. See http://developers.facebook.com/blog/post/510/ for details.

Related

wall post on facebook from hybrid mobile application

I am having a hybrid mobile application(should work in android and ios). In which I need to post on facebook wall from my application. Please note its a hybrib app, so I am not supposed to use any java or c code.
I tried the following method , its working in simulator , but not in actual device. Please help me.
<script>
window.fbAsyncInit = function() {
FB.init({
appId : ' my appID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
<script type="text/javascript">
$(document).ready(function(){
$('#share_button').live('click', function(e){
e.preventDefault();
FB.ui(
{
method: 'feed',
name: 'HyperArts Blog',
link: 'http://hyperarts.com/blog',
picture: 'http://www.hyperarts.com/_img/TabPress-LOGO-Home.png',
caption: 'I love HyperArts tutorials',
description: 'The HyperArts Blog provides tutorials for all things Facebook',
message: ''
});
});
});
</script>
Thanks
I ran into this. your:
document.location.protocol
which is suppose to pull in the FB SDK is actually "file:///" and thats what gets fed into the url for that FB JS library.
Manually specify http:// or https://
This didnt work for me either on safari webView on IOS so i had to hit the endpoints manually using AJAX.

Facebook Connect Facepile error

I've developed a simple website using facebook connect, and it has been working fine for the last month or so. Underneath the fb:login-button code is a fb:facepile. It has worked as expected until today, when instead of showing friend's pictures it displays the facebook homepage. Here is a screenshot of the problem http://i.stack.imgur.com/nZsbq.png
Here is the relevant code. It worked at one time, so I'm really confused what happened to cause this weird error. Any help would be greatly appreciated.
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({appId: '<?php echo $appkey; ?>', status: true, cookie: true, xfbml: true});
/* All the events registered */
FB.Event.subscribe('auth.login', function(response) {
// do something with response
login();
});
FB.Event.subscribe('auth.logout', function(response) {
// do something with response
logout();
});
};
(function() {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
function login(){
document.location.href = "<?php echo $base_url.'/facebook/'; ?>";
}
function logout(){
document.location.href = "<?php echo $base_url.'/logout/'; ?>";
}
</script>
I cannot copy the two XFBML tags that follow the javascript. They are fb:login-button and fb:facepile
It is a reported bug but it seems that nobody at Facebook care about it. Very strange and disapointing for such big web company.
http://forum.developers.facebook.net/viewtopic.php?id=90734
You can report this bug by upvoting at the follwoing webpage :
http://bugs.developers.facebook.net/show_bug.cgi?id=15490
It looks like <fb:facepile></fb:facepile> is finally working again. The bug was marked as resolved on the Facebook bugtracker and is currently working as expected on my development server.

What is the best way to use old Facebook REST API and new Facebook Graph API on the same webpage?

The existing page has code to work with the old REST API:
jQuery(document).ready( function() {
FB_RequireFeatures(["Connect", "XFBML"], function() {
FB.init('12345678ABCDEF','/xd_receiver.html', {ifUserNotConnected: fb_user_not_connected}); // real key replaced by 12345678ABCDEF
which is to support "Login with Facebook" and "Share" button to share story on Facebook.
If the following code for new Graph API is added
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: '123456', status: true, cookie: true, // real appId replaced by 123456
xfbml: true});
};
jQuery(document).ready( function() {
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
})
</script>
then the "Share" and the "Login with Facebook" stopped working. I realize the different code each calls its FB.init(), one with 2 strings and 1 object, and the other calls FB.init() with just one 1 object. Is one overriding the other FB.init()?
There are some people who think it cannot work:
http://forum.developers.facebook.net/viewtopic.php?id=66057
Can Facebook's Javascript SDK work together with the older Facebook API?
and some people who think it can:
http://forum.developers.facebook.net/viewtopic.php?pid=278718#p278718
http://github.com/mmangino/facebooker2/issues/closed#issue/18
Both APIs are available from new JS client. You're mixing the terms "API" and "JS client". You can (you should) use new client and make request to both REST and GRAPH APIs as well.

facebook fb:login-button for mobile web

I'm trying to fb:login-button work for mobile web, a la: http://developers.facebook.com/docs/guides/mobile/
However, I'm not sure where to add this code: &display=touch
My FBML is the standard:
<fb:login-button autologoutlink='true' perms='user_about_me,email'></fb:login-button>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({ appId: 'XXXXXXX', status: true, cookie: true, xfbml: true });
FB.Event.subscribe('auth.login', function() {
location.href = "....";
});
};
(function() {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
} ());
</script>
Any ideas?
I'm pretty certain you're not able to use the FBML tags for mobile web applications. At least, they won't accept the display=touch argument.
It means you'll need to use the slightly more complex OAuth implementation that they describe on http://developers.facebook.com/docs/guides/mobile/
It kinda makes sense if you think about it. The FBML tags generally rely on popups or overlays, which you can't really be certain will be compatible with all mobile browsers. The OAuth implementation takes you off to a FB page and returns you back to your host site for authentication and authorisation.

integrated facebook facepile need

I am working on project, it needs facepile (plugin of facebook) in index page,
how can I do it?
you need to get an appID from facebook developers site. (http://developers.facebook.com/setup/)
then..
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: 'YOUR APP ID HERE', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
THEN...
place this into your page:
<fb:friendpile width="210"></fb:friendpile>
or whatever feature you need.
try this link for more: http://developers.facebook.com/docs/reference/javascript/
Is this showing the Facepile of a page or the user himself (me)?
I tried your code but it always shows a login frame also if I'm already logged in to Facebook.
My target is to have a list of Fans and posts of a specific page for my website.