Facebook request dialog inside app
I'm trying to popup a request dialog (of the list of friends) inside the canvas app, but I'm having troubles and I'm not finding any help on tutorials.
Here the code after the authentication, etc.
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : '[**myid**]',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
</script>
<button id="send-to-many">Send to Many</button>
<div id="fb-root"&开发者_如何学Gogt;</div>
<script>
document.getElementById('send-to-many').onclick = function() {
FB.ui({
method: 'apprequests',
message: 'You should learn more about blabla].',
}, Log.info.bind('send-to-many callback'));
}
</script>
any ideas or any examples of how to initiate the JS on a FB canvas?
The problem is that the second parameter in the FB.ui() function is supposed to be a callback function. Try removing it and either replace it with null or a function that is defined or with an inline function. If you do need to call Log.info.bind, make sure the function is defined and the defining script gets included. For now, try something like:
<script type="text/javascript">
document.getElementById('send-to-many').onclick = function() {
FB.ui({
method: 'apprequests',
message: 'You should learn more about blabla].',
}, function(response) {
//Log.info.bind('send-to-many callback'));
alert('callback called');
})
}
</script>
Facebook documentation has examples and code for what you are trying to do. Check their requests documentation.
If you want to use the Log.info.bind
, change it to console.log()
<script>
document.getElementById('send-to-many').onclick = function() {
FB.ui({
method: 'apprequests',
message: 'You should learn more about blabla].',
}, Log.info.bind('send-to-many callback'));
}
</script>
精彩评论