allowing people to send invitations for a website to their friends - facebook

I would like to allow users on my website to send invitations TO my website to their facebook
friends. What is the best way to do this?
Is there a simple snippet of FBML code I can attach to a button on my site?
Must the users first be logged into facebook?
In the developers documentation here:
http://developers.facebook.com/docs/reference/fbml/req-choice/
It says "Note: You can also send requests and invites through Inbox."
What does this mean?
Thanks.

In all honesty, the simplest way is to use Like. Add in the correct Open Graph tags and you will have your website published on their wall. By using Like, if the person isn't logged into Facebook, it handles all of that side of things for you.
EDIT
http://facebook-developer.net/2008/02/20/allow-your-users-to-invite-their-friends/
EDIT
You said you wanted to invite people to your page. Here is the code:
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js">
</script>
<script>
FB.init({
appId:'YOUR_APP_ID', cookie:true,
status:true, xfbml:true
});
FB.ui({ method: 'apprequests',
message: 'Here is a new Requests dialog...'});
</script>

Related

Facebook Share API - options for "link"

I'm struggling to create my first Facebook share feature on a website and the issue is a dynamically created link. I'm trying to share a referal link to (i.e. come checkout ecommerce site and get $20 back).
<script type="text/javascript">
$(document).ready(function(){
$('#share_button').click(function(e){
e.preventDefault();
FB.ui(
{
method: 'feed',
name: 'Want $20 off Sailormade bracelets for summer? Shop now and thank me later',
link: '<?php echo $this->getReferrerLink();?>',
picture:'http://shop.sailormadeusa.com/media/wysiwyg/raf/refer_a_friend_static_block.jpg'
});
});
});
First timer on the Facebook app, and first timer posting here on stackoverflow. Go easy on me, and let me know if I can provide any additional information. THanks!

Facebook apprequests not working

I have following code in html file:
<html>
<head>
<title>My Great Website</title>
</head>
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js">
</script>
<script>
FB.init({
appId:'156154681125939', cookie:true,
status:true, xfbml:true
});
FB.ui({ method: 'apprequests',
message: 'Here is a new Requests dialog...'});
</script>
</body>
</html>
I am using this code to send apprequests for my app (reference: http://developers.facebook.com/blog/post/464/)
Problem: I am able to load Request dialogue by above code, and it shows my friend list. Also I can send invited then. Say suppose I send the invite to friend "X" (provided "X" is not already using my app). Then in X's FB account, apprequest bookmark count is increases by 1. But when X is trying to see app invite, he actually cannot see any app invite received for my app. I have tried this with at least 5 users, all are getting their apprequest book incremented by 1 after I send the invite to them, but when they see the invite, there is actually no invite present.
Can anyone suggest me that what is the problem?
Note: My app is website (and not canvas app), also I have hosted above demo code on my server at http://www.gmarjil.com/a.html
This is the expected behavior of non-canvas applications. Requests always redirect to the application's canvas URL and if it is not set the request is not displayed.
The request is still sent (this is why the requests count is increased), you can access it via the graph API (https://graph.facebook.com/{user_id}/apprequests, needs app access token).
Even if your app is not a game you can give any url as the canvas uri in the facebook app setting.The url even if invalid will allow teh notifications to send.This solved my issue.

Invite friends dialog

I have an invite dialog on my page:
<a href="#" onclick="sendRequestToManyRecipients(); return false;" >xx</a>
<script language="javascript" type="text/javascript">
FB.init({appId : 'myappid', status : true, cookie : true, oauth: true});
function sendRequestToManyRecipients() {
FB.ui({ method: 'apprequests', message: 'xxx'},requestCallback);
}
function requestCallback(response) {
// Handle callback here
}
</script>
When the invited user clicks the invite, he gets linked to the app, but I want the user to get redirected to a page like http://www.facebook.com/pages/xxx/xxx?sk=app_xxxx.
How can I do that?
That's not possible without some custom coding - the requests interface exists to drive traffic to apps on facebook, not to page tabs, there's no way to have Facebook send users to a tab when they accept the request.
You could just implement something on your canvas landing page that redirects users back to a page tab based on the information in the request as a workaround.
previous version of the apprequest which is request-form this was possible: How can I include a link in a FB app request?
However current version of apprequest : facebook guys lets only redirect to your app: https://apps.facebook.com/yourapp
#Vihay comments helps this custom workaround to redirect to page.
Hoping next version apprequests, facebook enables redirect to links within the fb app.
Agree with previous answers. Facebook will redirect to your app, which is just a Facebook wrapper around a page you can provide. That page can then use a client-side redirect to whatever page you'd like (like what Klout does).

Facebook Request Dialog - Invite to External Website

FB.init({
appId:'Application ID', cookie:true,
status:true, xfbml:true
});
FB.ui({ method: 'apprequests', message: 'Here is a new Requests dialog...'});
How to redirect the user to my external website rather than the Canvas Page inside facebook?
There are a couple posts about this online that suggest making a dummy canvas page that sets
window.location.top = 'yoursiteurl'
... but this does not seem satisfactory to me. Facebook docs are wildly unclear about whether external website ("Facebook Connect") devs are encouraged to use requests.

Adding custom actions to facebook comment plugin

I am currently using the normal facebook comments plugin as such:
<p class="fb-comments"></p>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js#appId=API_ID&xfbml=1"></script>
<fb:comments href="URL_OF_PAGE" num_posts="10" style="max-width:480px" width="300"></fb:comments>
I have a custom login section. but I want to be able to see who posts a comment on the website if they are logged in.
In other words this is exactly what I want to accomplish.
if the user is logged in, and they post a comment, I want to be able to store the ID (or username, email, etc) of the user thats logged in - into my DB.
if they are not logged in then i dont care to track it.
any one have any thoughts?
Subscribe to the comment.create method in javascript and then the check values in the response variable.
FB.Event.subscribe('comment.create', function(response) {
alert(JSON.stringify(response);
});