Have you noticed 'bring your friends' button or link on web pages? Want to add it to your website and let users invite their facebook friends? This is how you do it!
First, u need to have a facebook APP. If don't have one, have a look at
this Create your Facebook APP for website.
FB.init({
appId:'APP_ID',
cookie:true,
status:true,
xfbml:true
});
function FacebookInviteFriends()
{
FB.ui({
method: 'apprequests',
message: 'Your Message diaolog'
});
}
</script>
<div id="fb-root"></div>
<a href='#' onclick="FacebookInviteFriends();">
Facebook Invite Friends Link
</a>
www.techoyo.com (c) Ganesh Venkataraman
First, u need to have a facebook APP. If don't have one, have a look at
this Create your Facebook APP for website.
Now, you also need to add Canvas for your APP. This is how you do it by editing APP information:
Click on 'save changes' button.
Now, place this code in your web page:
Now, place this code in your web page:
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>FB.init({
appId:'APP_ID',
cookie:true,
status:true,
xfbml:true
});
function FacebookInviteFriends()
{
FB.ui({
method: 'apprequests',
message: 'Your Message diaolog'
});
}
</script>
<div id="fb-root"></div>
<a href='#' onclick="FacebookInviteFriends();">
Facebook Invite Friends Link
</a>
You must change 'APP_ID' in the above code.
You can also change the 'Your message dialog' as desired.
You can also change the 'Your message dialog' as desired.
Code IFrame
The following code is for breaking Iframe, include this code into your webpage.
The following code is for breaking Iframe, include this code into your webpage.
<script type='text/javascript'>
if (top.location!= self.location)
{
top.location = self.location
}
</script>
if (top.location!= self.location)
{
top.location = self.location
}
</script>
You are done now. This is what you'll see as an invite screen on clicking the link on your website:
You are awesome man...
ReplyDeleteBut please help me I have this error
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: redirect_uri is not owned by the application.
^Many come up with this problem. If you use the code on local host, the code won't work. That is because in your set up, you would have specified redirect_uri as your site URL. If you upload it to your server, it should work fine. If you want it work on local host, make site URL : http://localhost:8080/
ReplyDeletehttp://localhost:8080/ is also not working, any localhost url is not working. so is it compulsory to have website hosted for fb invite friends on website?
DeleteHello, thank you for your code,
ReplyDeleteI have problem, I have the popup and I can choose friends and confirm send request but no thing happens ! request don't arrive to friends
have you any idea please ?
Probably you don't have a SSL certificate for the website that you are running your code on.
DeleteThank you for your answer, yes that's true I don't have a SSL certificate for the web site,
Deleteby modifying some parameters in the app configuration, friends have the notifiaction of the request but there are nothing, the page contain just the header of facebook and no others information,
sorry may be I'm not very clear in my explication, that's the first time I work with facebook application :),
thank you.
i use this and send invite but that invite view the person that time error come that is
ReplyDeleteError code: ssl_error_rx_record_too_long
Hi please check this here is a running script of facebook invite friend api with example.. http://phpsollutions.blogspot.com/2014/02/facebook-invite-friends-api-in-php.html
ReplyDeletethanks Bro
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteit opens up the dialog box but with a msg that "Game Requests are only available to games.".
ReplyDeletewhat should i do?? please help
Error : Game Requests are only available to games.
ReplyDeleteplease help me
Very entertaining information. found a lot of things for yourself useful. denver air conditioning repair
ReplyDeleteHello Admin, thank you for enlightening us with your knowledge sharing. PHP has become an inevitable part of web development, and with proper PHP training in Chennai, one can have a strong career in the web development field.
ReplyDelete