Facebook app - permissions varying from tester to tester - facebook

Bit of an odd one: I've created an app that uses a jQuery AJAX request to query the Graph API and access a list of a given user's Likes (someone on my Friends list). I can use this within my app, and I get the same result as if I'd run the query through the Developer tools Graph API Explorer site (https://developers.facebook.com/tools/explorer).
The fun begins when people on the Testers list for the app (which is sandboxed) perform exactly the same actions, with the same friend (who isn't on the testers list); they don't receive any data back from the Graph API at all.
The testers have granted my app all the same permissions as I have, so why would we be getting different results?

Finally - I think I've found the solution.
By switching the Facebook JavaScript SDK file to a direct link rather than an asynchronous download, and calling the FB.login function with extra permissions defined in the scope later down the page:
FB.login(function (response) {
if (response.authResponse) {
// init app here
} else {
// cancelled
}
}, { scope: 'user_likes,friends_likes' });
... the testers are able to access their friends' Likes. Phew!

Related

How to reward members for having their invites accepted in Facebook canvas app?

I'm using the following Javascript for my users to send requests to "invitable friends" from my Facebook app:
FB.ui({
method: 'apprequests',
message: 'Come play with me etc.',
to: str_ids
},
requestCallback
);
function requestCallback(response){
if(response){
console.log(response);
}
else{
//show error to user
}
}
Where str_ids is a string containing the IDs returned by the invitable friends API. This all works fine.
When I invite a single user, let's say his Facebook ID is 1593894704165626, I get the following response:
request
"1399842883640198"
to
["1593894704165626"]
So here I have a unique request ID and the invited person's Facebook ID. I can now store this data in my database along with the inviter's ID, so I have all the necessary info.
However, now I want to reward the inviter after the invitee accepts the invitation and I'm running into a problem.
If user A and user B both invited user C, then when user C joins the game, how do I know whether to reward A or B?
I see from this question that it's possible to pass another parameter along with the invitation, which should help identify the inviter:
Facebook tracking who Invited whom
The first answer here suggests that you can pass such a custom parameter, but doesn't say how. Facebook's convoluted documentation is driving me insane.
Another thing - even if I send that additional parameter, I think there's a problem - for new users the app redirects to the Facebook page that checks whether they want to allow access to the app, and by the time they're redirected back to the app, the additional parameter will be lost.
Is there any solution to this?

How to programmatically invite Facebook friends on a website

The functionality that I need is to show a list of Facebook friends to the user on the website page with custom design, where the user can select some of them and send invites.
In API v2.0 it's possible to get a list of friends this way:
FB.api('/me/taggable_friends', function (response) {
...
});
But it doesn't return real users' ID that I need for invites with the next function call:
FB.ui({
method: 'apprequests',
message: invite_text,
to: 'user_id_1, user_id_2'
}, function (response) {
...
}
);
How can I get these real IDs?
Or how to resolve this functionality in another way? Because all the answers that I found were connected with games that don't fit me.
I need a full list of friends. Not just that already use my website (analog of the invitable_friends in-game section).
You are not allowed to use taggable_friends for inviting them, obviously it is for TAGGING friends and you only get a tagging token.
There is invitable_friends, but:
The invitable_friends API is only available for games that have a Facebook Canvas app implementation using version 2.0 of the Graph API.
(https://developers.facebook.com/docs/games/invitable-friends/v2.1)
I am afraid what you want to achieve is not possible. The proper way to invite friends to your website is to use the Send Dialog: https://developers.facebook.com/docs/sharing/reference/send-dialog
You can include one User ID in the "to" parameter. Of course it must be a User who authorized your App too, you can get those with /me/friends. Or better: Just open the Dialog and let the User select on his own.

Cannot list Ad Accounts in facebook app

I'm developing a pure-html/js web application (actually I'm using AngularJS; with "pure" I mean: I'm not using any server side technology) which uses a Facebook-Connect button like this:
<fb:login-button max_rows="1" size="xlarge" scope="email,public_profile,ads_management" show_faces="false" auto_logout_link="false"></fb:login-button>
Such button asks for permission: ads_management and basic user data. I'm testing ad-management functionality.
However, I ask two queries to facebook inside a controller:
$scope.fetchData = function() {
FB.api('/me', function(response){
$scope.$apply(function(){
console.log("InApp::fetchData()");
console.log(response);
console.log("~InApp::fetchData()")
});
});
};
$scope.fetchAccounts = function() {
FB.api('/me/adaccounts', function(response){
$scope.$apply(function(){
console.log("InApp::fetchAccounts()");
console.log(response);
console.log("~InApp::fetchAccounts()");
});
});
};
$scope.fetchAccountData = function(account_id) {
};
$scope.fetchData();
$scope.fetchAccounts();
For narrow-purposes I just printed the contents of a controller. Assume such controller exists, requires the person is logged in Facebook, and the user is currently logged in.
My Issues are:
The Login button does not update the page when I login. This is because no onlogin= was put. Question: How can I assign such attribute in an Angular way? (i.e. the handler coming from the scope).
$scope.fetchData is successfully executed. However, $scope.fetchAccounts is not. I'm asking this because I included the ads_management permission in the button. Question: What am I missing? (error: code: 10
message: "(#10) You do not have sufficient permissions to perform this action"
type: "OAuthException"). Edit - Additional notes: I deauthorized the application in my account, and reauthorized it: It never asks me the ads_management permission in the popup dialog.
The first question, no idea. The second question, your app is not whitelisted for Ads API usage. Look into the Ads APi documentation on how to request access.

Facebook Javascript SDK feed doesnt contain status updates

Here is the code for fetching the activity feed from Facebook Javascript SDK
function fetchFeed(){
FB.api("/" + {My-User-ID} + "/feed?limit=5", function (response) {
if (response.error) {
console.log("Error fetching feed");
} else {
console.log(response);
}
});
}
But the feed obtained doesn't fetch me the status updates from my account , it fetches my other activities like page likes but not the status update .
I think that's because your Access Token is missing some of the permissions required to obtain the user statuses. These permissions are user_status and read_stream. If you are using Javascript SDK for authentication, you can ask for extra permission in the code using:
FB.login(function(response) {
// handle the response
}, {scope: 'user_status,read_stream'});
You can always test your code using the Graph API Explorer. It gives you flexibility to manually choose the permissions and test you queries.
PS: If you are only concerned about the statuses, you can use API endpoint like /{user-id}/status and /{user-id}/posts to narrow down your results. Take a look at the documentation on /{user_id} edges to find out the difference among these edges.
Thank you Rahil for the suggestion , The Graph API Explorer Page helped me to find out the solution, my app (PI CONTROL) didn't have the right permissions in its access token to fetch status updates . LAter Obtained a new access token with right permissions for my application. The steps are depicted in the screenshots below
1.Go to the Graph Explorer Page Graph Explorer
2.Select the app for which you want to give the permissions for
2.Click on Get Access Token
3.Select the right permissions for your app

Facebook public posts I make using the Open Graph API are not seen by friends

I'm making a simple Facebook app that posts updates to the user's timeline using node.js and Facebook's Open Graph API. Even though I can see the posts I make using the OG API on my timeline (and it has the globe icon identifying that it's a public post, see pic below), none in my FB friend network can see it.
Here's a screenie of a public post I made via OG API showing up on my timeline, along with a post from a 3rd party app (Pool practice) for comparison:
Now here's the screenie of my friend's timeline showing only the Pool Practice post, the post from my app is nowhere to be seen...
I've checked the app settings and permissions as well as the OG API options, but haven't seen anything that points to how I can solve this problem. Here's the node.js code I'm using to post the updates:
// app permissions set to 'publish_actions' and 'publish_stream'
// I do the auth dance here to get the access_token and store it in session as fb_token
var request = require( 'superagent' ); // module from TJ Holowaychuk similar to "request"
request
.post( 'https://graph.facebook.com/me/feed?access_token=' + req.session.fb_token )
.send( { message: 'posting via node.js' } )
.set( 'Content-Type', 'application/x-www-form-urlencoded' )
.end( function( response ) {
log( response );
});
The code above works and the post shows up on my timeline, but no one else is able to see it.
Anyone know a way out of this?
you need to submit each action for Facebook validation before your friends can view it. Only users defined as developpers for the app are allowed to view those timeline messages.