I am new to stack overflow, how can I invite my Facebook friends to my Facebook application pro-grammatically using javascript SDK? I am a newbie regarding Facebook-Javascript. I want to send an invitation to a user's friends using my Facebook application.
I am new to stack overflow, how can I invite my Facebook friends to my Facebook application pro-grammatically using javascript SDK? I am a newbie regarding Facebook-Javascript. I want to send an invitation to a user's friends using my Facebook application.
Share Improve this question edited Sep 17, 2012 at 8:47 Daedalus 7,7225 gold badges38 silver badges63 bronze badges asked Jul 26, 2011 at 12:17 Eslam SolimanEslam Soliman 1,2965 gold badges17 silver badges42 bronze badges 1- Keep in mind you can only invite people to a game. – Jack Marchetti Commented Jan 26, 2016 at 17:55
2 Answers
Reset to default 10Here is my code, uses jQuery:
$('#popInvite').live('click', sendRequest);
function sendRequest() {
FB.ui({
method: 'apprequests',
message: 'Bee my Buddie',
filters: ['app_non_users'],
title: 'Bee my Buddie'
},
function (response) {
if (response && response.request_ids) {
//if sucess do something
//How many people did the user invited?
var $howManyInvites = String(requests).split(',').length;
} else {
// alert('canceled');
return false;
}
});
return false;
} ;
here is the code and gone function is to get your appId from the path you can change it and do not forget the fbroot div :
invite
<script src="http://connect.facebook/en_US/all.js" type="text/javascript">
</script>
<script type="text/javascript">
FB.init({
appId: gone(), cookie: true,
status: true, xfbml: true
});
function shareWithFacebook() {
FB.ui({ method: 'apprequests',
message: 'Here is a new Requests dialog...'
});
}
function gone() {
var pathname = window.location.pathname;
var appId = pathname.split('/')[1];
return appId;
}
</script>