Facebook apprequests not working - facebook

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.

Related

Application doesn't authenticate in canvas

My facebook application redirects the user a page where they give the application window correctly when they visit the website (http://toolshed.herokuapp.com/), but not when they visit the canvas page in Facebook (https://apps.facebook.com/toolshed/). Once a user has given permission to the application, both places work correctly. The main problem here is that when a user goes to the page on Facebook first, all they see is a blank page. Any ideas? The code can be found at https://github.com/runninggraeb/toolshed, but I doubt it's a coding issue. Any help would be appreciated.
Ryan
Answer: To clarify to future viewers, I did redirected to this page within the app for authentication. "top.window.location" gets me out of the iFrame.
<!DOCTYPE html >
<html xmlns:fb="http://ogp.me/ns/fb#" lang="en">
<script>
window.top.location = '<%= authenticator.url_for_oauth_code %>'
</script>
</html>
You can not display the Auth dialog in any kind of frame. (As has been said here already many times before …)
You have to redirect to it in the top most window instance.

Facebook Send dialog gives 100 error when sending Facebook urls

I'm using the Facebook send dialog to send links to Facebook posts. But I get the following error back from the Facebook API:
API Error Code: 100
API Error Description: Invalid parameter
Error Message: 'link' is invalid.
This is the JavaScript:
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
// assume we are already logged in
FB.init({appId: '569858063028330'});
FB.ui({
method: 'send',
link: 'https://www.facebook.com/benjerryuk/posts/10151500944440101'
});
</script>
You can run it here:
http://jsbin.com/welcome/62834/edit
Facebook send dialog documentation: https://developers.facebook.com/docs/reference/dialogs/send/
I couldn't find it written specifically, but from my attempts it seems that facebook does not accept links to itself for some reason - I can't confirm this, but I got the same result even when I put links of public posts or profiles.
You might have the link refer to your app, which will redirect to the correct facebook post.
Another note: while showing this dialog, facebook loads the given link with AJAX, which means that A) it must be an active URL and B) you cannot use localhost.
Hope that helps.

add app to facebook fan page error

I am trying to add an app to my facebook fan page account for oAuth login.
I DONT WANT A TAB so the method i thought might work was method: 'apprequests'
but i keep getting an error: An error occurred with Prayerfish Login. Please try again later.
any suggestions on how to get the app over to my fan page?
note** this html page is from facebooks tutorial
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<title>My Add to Page Dialog Page</title>
</head>
<body>
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p><a onclick='addToPage(); return false;'>Add to Page</a></p>
<p id='msg'></p>
<script>
FB.init({appId: "****************", status: true, cookie: true});
function addToPage() {
// calling the API ...
var obj = {
//method: 'pagetab',
method: 'apprequests',
redirect_uri: 'https://www.myDomain.com',
};
FB.ui(obj);
}
</script>
</body>
</html>
The only way to have an app on a Facebook Page is to add it as a "tab". Since the switch to Timeline, tab has become a bit of a misnomer as it is more correct that it is just a bookmark at the top of your Page (for example on Spotify's Page the 'Get Spotify', 'Fan Playlist' and 'Summer Sounds' thumbnails at the top of the page are technically 'Page Tabs').
If you still want to add the app to your Page as a 'tab', the code you included above is actually more complex than you need. That code is what you would include on your website, for example, if you wanted to allow admins of other Facebook Pages to install your app. Because you own both the Page and the app, you just need to modify this link to include your app ID and URL and click on it:
https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&display=popup&next=YOUR_APP_URL
When you do, you'll see a dialog asking you to pick which Page you want to add the app to, choose that and you're done.
If you were already aware of what a Page Tab is and don't want that, my question would be - how do you want the app to appear?

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).

allowing people to send invitations for a website to their friends

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>