I can't get this working. I'm trying to show something like this (see the image image from the "send to many" section). I'm getting the message "An error occurred. Please try again lat开发者_如何转开发er."
The code:
window.fbAsyncInit = function() {
FB.ui({title: 'title', display: 'iframe',
method: 'apprequests', message: 'check this out.'
});
}
Edit1: The popup window shows, but inside it there's no list of friends but the above message.
Edit2: And of course my app requests permissions for user's friends list on first launch.
I have tested your code and I get the dialog load with all the users.
I would suggest checking your application id to make sure it is correct.
Below is the code I am using:
//run the script code to get the facebook javascript sdk
(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);
}());
//run when sychronisation of facebook javascript sdk is finished
window.fbAsyncInit = function(){
//initialise the application
FB.init({appId: '<?=APPLICATION_ID?>', status: true, cookie: true, xfbml: true, oauth: true});
FB.ui({title: 'title', display: 'iframe', method: 'apprequests', message: 'check this out.'
});
};
You should use the function getLoginStatus, to be sure that the FB.init
function has finished to load.
I just solved same problem this way:
note that I'm using jQuery
<script type="text/javascript">
$(document).ready(function () {
FB.init({ appId: 'APP_ID', status: true, cookie: true, xfbml: true, oauth: true });
FB.getLoginStatus(function (response) {
FB.ui({ title: 'Invite friends', display: 'iframe', method: 'apprequests', message: 'check this out.' });
});
});
</script>
<div id="fb-root"></div>
精彩评论