I am using OAuth Dialog for Facebook permission to access a users' email, birthday and other details but when I run this app URL that is https://apps.facebook.com/projectatestapp/ (while being logged into Facebook) I see this login to app window which says:
You are logging into testapp as Nina Sewart. Logging in will not add this app's activity to Facebook.
With log in and cancel button instead of Permission window with Allow and Don't Allow button
here is my code
<html xmlns:fb="https://www.facebook.com/2008/fbml">
<body>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<div id="fb-root"></div>
<script>
FB.init({
appId: '[My app id]',
xfbml: true,
cookie: true,
oauth: true
});
FB.login({
scope: 'email,user_birthday',
});
</script>
<a href="https://www.facebook.com/dialog/oauth/?scope=email,
user_birthday&
client_id=148244388606048&
redirect_uri=https://apps.facebook.com/projectatestapp/test2.html&
response_type=token" target="_top">test</a>
</body>
</html>
Please tell me whats wrong in it?
The reason you are not seeing it is because the application process has become a two step process.
Being that the person accepts to login into your application.
Being the person accept your extended permission which is where the callback url comes into play.
Documentation can be found here.
So the reason your callback isn't being called is because the two step process. I would suggest making the response attached to second page that is called.
I am not sure how the JS SDK works but it is how I managed to do it.
Goodluck.
You need before calling autorization window to add the fb token to the url to identify your user to fb.
I think try this to get the token : FB.getAccessToken();
I have the same issues here. The documentation says only developers/tester of this app will be able to get the publish permission but I could manage to make it work only with the id that was used to create the app. Other test users (even though are authorized developers) are not able to get past the 'add-to-timeline' stage.
It could be a major bug.
I was struggling with this issue for few hours, and my lovely co-worker helped me fix it just now. Make sure you don't refresh the page after login was called. Basically, don't do something like below:
FB.login(...);
window.location.refresh();
Include the refresh code inside of the callback for FB.login!
Man, I feel so stupid, but sometimes you get confused and forget how callbacks work in terms of execution orders of code.
Related
Im making an application on Phonegap, and therefore using javascript. I have added the facebook plugin, and everything seems to work fine. The user can log in and make app requests to friends using the FB.ui:
FB.ui({method: 'apprequests',
message: 'Try this application, and get ready to Guess This Sound!'
}, requestCallback);
The dialog pop up, and when I send an invitation my requestCallback method return OK
function requestCallback(response){
alert("response " + response);
}
However, my friends do not receive any notification about the request. My application is no longer i sandbox mode, and I can't figure out whats the problem is. Since Im using phonegap, I have added ios and android platform on facebook, and I guess no canvas URL is needed.
UPDATE
Some users do now receive the notifications from the application, but not everyone.However, when my friend clicks on the notification he receive this message: "The requested page can not be viewed right now. It could be temporary unavailable." Is it because my application is not available on google play and app store for the moment?
You have to Add app in your developer account
facebook -> Apps -> "You app" -> Setting -> add platform -> App on Facebook -> Add any URl
Now you will get app request notification
The problem was due to wrong set up in facebook developer API. The error still remains, but is because the app is not released yet. To see the solution to this, see:
Facebook invite request error android
I've implemented a like widget which it's URL parameter is set to
"http://www.justanexample.com#!home|mainPage"
the (relevant) meta-tags for this page:
<link rel="canonical" href="http://www.justanexample.com"/>
<meta property="og:url" content="http://www.justanexample.com"/>
still when a user likes the page and posts the message, the link is:
"http://www.justanexample.com?_escaped_fragment_=mainPage"
My assumption is as follows:
when Facebook scraper requests the page - the _escaped_fragment version should return
when user ask the page, he requests the URL with the hash-bang (e.g. "http://www.justanexample.com#!home|mainPage") or without it.
when posting to facebook, the link should be as the URL I set ("http://www.justanexample.com#!home|mainPage"), and therefore when the user clicks this URL it will work the same as (2).
but why does Facebook change my URL to the _escaped_fragment?
could someone please explain where is the problem here?
Thanks!
P.S.
i'm aware of: http://facebook.stackoverflow.com/questions/8653183/facebook-share-showing-escaped-fragment-url-instead-of-hash-version
and understand it solves the issue, but before using it, I want to first understand what's the cause of this behavior.
We have an application that allows to users publish content to their friends wall.
It uses the user's access_token given our application.
It works stable usually, but for some reason for one of our clients it doesn't work at all.
We've checked permissions several times, removed-added them again, but still no result.
There is no error message or something, everything looks fine, complete the action, but no posts published in fact. And it doesn't work only for one person.
What possibly can be a problem?
Updated: The problem is actually in this OAuthException:
Error validating access token: Session does not match current stored
session. This may be because the user changed the password since the
time the session was created or Facebook has changed the session for
security reasons.
We tried to get access token one more time, but that didn't help. Somebody familiar with this issue?
your user might forbid people/applications to post on his wall.
"There is no error message or something, everything looks fine, complete the action, but no posts published in fact."
Are you sure about this? You should be getting back a unique stream id of the feed item just posted.
Facebook frequently changes its policies that sucks!
Now, you need permission to access the wall.
You need to check if the user has permission to access your application / wall page. if user hasn't got permission then you need to ask for permission before message is streamed. Yes, that's true, it won't display any error message, unless you manually debug this to see where it is stopping.
My suggestion is:
1. use FB.login method to verify, if the user is not logged in then he should login
2. verify the user permission for the wall page
FB.api('/id', function(response){});
3. publish / stream the comments on wall
FB.api("/id/feed", 'post', { ... blah blah blah !
edits:
At FB.login method, you should ask for permisions
e.g. FB.login(function(response) {..} ... ,{scope: 'offline_access,publish_stream'});
I'm fairly new to the Facebook API, but I've tried to do my due diligence to figure this out, but I can't seem to. I'm simply trying to get a list of the logged-in user's albums, using various techniques, to no avail. I'm using the JavaScript SDK, and I have the following code:
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId:'{MY_APP_ID}',
cookie: true,
status: true,
xfbml: true,
oauth : true
});
FB.login(function(response) {
if(response.status === 'connected') {
FB.api('/me/albums', function(response) {
console.log(response);
});
}
}, { scope : 'user_photos' });
</script>
Note that {MY_APP_ID} is actually my application ID. So, when this executes, the popup will request access to the users photos, and that works fine. Now, in code, response returns a data array that contains no elements. In addition to trying the above, I've tried initiating a JSON request to the following URL as well as directly visiting it in the browser:
https://graph.facebook.com/me/albums?access_token=" + response.authResponse.accessToken
And this returns an empty data array as well. The access token that I'm using is coming either from the FB.login method or FB.getLoginStatus. Any help would be greatly appreciated. Thanks in advance.
So, I figured it out, so I will answer my own question. All the other answers on SO was related to permissions, but this wasn't it. It turns out that if I looked at my account settings (I'm the 'user'), and looked at apps, for this application, for some reason, it showed it only was requesting the email address. I knew this wasn't correct, because I was clearly asking for user_photos as well. So, after deleting the application from my profile, and reinitiating the connect, it looks like I'm able to access the albums fine. I'm not sure if Facebook intended to do this by design, but it seems like a potential bug to me.
This can also happen if you're using the JS SDK, as that authentication process and auth dialog are apparently complete separate from what you set up in the developer app.
You need to ALSO include the permissions you desire when you call FB.login() using the optional scope parameter, eg...
FB.login(function(response) {
if (response.authResponse) {
M.FB.setIsAuthorised(true);
// On success.
} else {
// On failure.
}
}, {
scope: 'email,friends_birthday,user_photos,friends_photos,publish_actions'
});
I had a similar issue. Several solutions on stackoverflow mostly attributed the issue to the lack of required permissions. Check the permissions you need by using the Graph API explorer or documentation (The tables have a column called permissions for each field).
Jonathan's solution actually gave me a clue about where I went wrong. I had a different issue where I had double-checked all the permissions set for my app dashboard that were correct, but while logging in, I had specified a scope with a set of permissions which seemed to override the app settings. :( I found this strange, but I rectified it by including the other permissions in the scope too and my problem was resolved.
An effective way to see if the right permissions are being set through the code is to use the following code:
FB.api({ method: 'fql.query', query: 'SELECT user_status,friends_status,user_photos,friends_photos,user_location,friends_location FROM permissions WHERE uid=me()' }, function(resp) {
for(var key in resp[0]) {
if(resp[0][key] === "1")
console.log(key+' is granted');
else
console.log(key+' is not granted');
}
});
P.S: Also make sure that if you changed the permissions in the app dashboard, you log out of your application and login again before testing.
I wasted over 3 hours trying to fix this issue and facebook documentation did not help me a bit, so hope this helps someone!
I am building a Facebook Connect application that runs inside a Google gadget. Being a gadget means that the application runs inside an iframe. Inside the application, there is a form that allows registered users to post comments. The submission is made using AJAX, but I get the same results with a normal form. The problem is that I need to get the user's facebook id. In Firefox, it works fine, but on Internet Explorer 7, I get the following error:
'A session key is required for calling this method'
I believe that this is due to the way IE handles third-party cookies, because if I go to Internet options / Privacy / Advanced, and check Override automatic cookie handling and accept all cookies, it works fine. I cannot pass the Facebook id from the javascript, because anyone could tamper it.
EDIT: If I open the content of the iframe directly, the app works fine. The problem is really due to the IFRAME and IE security model.
What am I doing something wrong? How can I work around this problem?
Have you tried adding a P3P policy ?
If the response setting the cookie has a compact policy, IE will use this to determine whether or not to allow the 3rd party cookie..
I solved the same problem by modifying how I check if the user was logged in on the PHP page following a FB connect login.
So, they login to FB Connect with IE7.
Next and subsequent page loads where I need to verify they are indeed logged into FaceBook I used the following code (note that $facebook->require_login() and other functions did not work - they returned null only in IE 7):
// Validate from Facebook that session is valid and user is logged in.
require_once 'facebook/facebook.php';
$facebook = new Facebook(YourAppsAPIKeyPublic, YourAppsAPIKeySecret);
$facebook->api_client->session_key = $this->userAPISessionKey;
$fb_user_id = $facebook->api_client->users_getLoggedInUser();
The $fb_user_id should now have a valid FaceBook user ID.
Regarding privacy policy and facebook connect + IE 7:
Although this didn't work for me it appears to work for others. in HTAccess:
Header append P3P "CP=\"HONK\""
or in PHP files:
header('P3P: CP="CAO PSA OUR"');
or
header('P3P: CP="HONK"');
reference: http://forum.developers.facebook.com/viewtopic.php?id=28636
ASP.NET:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
HttpContext.Current.Response.AddHeader("p3p", "CP=\"CAO PSA OUR\"");
}
I found a work-around that works, although it is a bit ugly: when the user clicks the 'login' button, it opens a popup that comes from my own site and which contains the Facebook Connect login button. After the user logs in, I close the popup and reload the iframe.
This is really ugly because It opens two popups, but at least it works. I will detect whether cookies are enabled using javascript and if they are enabled, I will skip the first popup.
I'm still open to better solutions...
Edit: Facebook now uses a "fake" popup inside my popup, instead of opening another window. Now I only have one popup which is ok for me.
you may want to see this thread also, which is created under facebook developer platform
http://forum.developers.facebook.com/viewtopic.php?id=452