in our apps we have the option to share activity on Facebook after which the users get a small reward. In recent days this feature has stopped working for some of our users because we didn't get "post_id" from your side which we need to determine if the user should get a reward.
We found out that this happens when the user hasn't given us the "publish_actions" right. Therefore we have added a check for this right and we try to request it this way:
FB.api('/me/permissions/publish_actions', function(response) {
// pokud mame pravo na zverejneni obsahu hned postujeme
if (response.data && response.data[0] && response.data[0]['status'] === 'granted') {
postShareReport();
} else {
// pokud nemame, tak si zkusime vyzadat pravo
FB.login(function(response) {
if (response.authResponse) {
// pokud nam ho dal, tak postujeme
if(response.authResponse.grantedScopes && response.authResponse.grantedScopes.indexOf('publish_actions') !== -1) {
postShareReport();
}
}
}, {scope: "email,publish_actions",return_scopes: true, auth_type: 'rerequest'});
}
});
However, here we encountered another problem. The publish_actions right is not requested from some users even though they haven't given us this right. The login process does go through, however. The user doesn't receive the window with the option to give us this right.
Thank you
Kind regards
Most permissions need to get reviewed by Facebook: https://developers.facebook.com/docs/facebook-login/review
Without review, publish_actions only works for users with a role in the App. Ohter users don´t get asked for the permission in the authorization process.
Btw, not getting a Post ID or information if the user really shared something is intentional, because rewarding the user in any way for sharing is not allowed. You need to read the platform policy before creating any App, that rule is in there since years:
Only incentivize a person to log into your app, enter a promotion on
your app’s Page, or check-in at a place. Don’t incentivize other
actions.
Source: https://developers.facebook.com/policy/
Related
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.
I created an Android App with PhoneGap:Build and the FB Connect Plugin. The app works fine and the FB Plugin, too. Just one tiny thing isn't working yet. I won't to post something after submiting a button which works, too. At the first time the user has to login and grant permissions to the FB App and them the post is published. That's the way it should be. And the next time the user submits the post should be published without the whole permission thing but this isn't working!? FB shows a message like "You already granted permission ... to the app." and the user has to push the Ok-button before the post is published???
Because I still haven't found an answer for my question, maybe I just do something wrong in my FB Javascript call? Here is the current code:
FB.login(function(response) {
if (response.authResponse) {
var data = {
...
}
FB.api('/me/feed', 'post', data, function(response) {
// Callback
if (!response || response.error) {
// ERROR
}
});
} else {
// ERROR
}
}, {scope: 'publish_stream'});
Well, to better understanding here a picture of the screen that apears every post:
http://i.stack.imgur.com/bZrde.png
Thx,
Daniel
I think the solution to this problem is to not include the login request every time you want to post something. You can check login status, and/or permissions, without performing a login. Then, if the user is not logged in, do the login first, and come back to the new post action.
I've an application that only asks for "user_about_me". Now I want to ask for new permission (publish_stream) but the response object returns "connected" if the user ignores the new permission. Because I want to post to the user's wall I'll get an error when posting to the user's wall "The user hasn't authorized the application to perform this action".
How can I do this?
I'm using Javascript SDK.
Basically you have to handle all the possibilities for user permissions/authorization when a user logs in. Here is a simplified working example from some FB integration I have done:
FB.Event.subscribe('auth.login', function(response) {
if(response.status === 'connected'){
FB.api('/me/permissions', function(resp) {
if(resp.data[0].publish_stream){
//User has permissions and authorization
}
else{
//User has not enabled publish stream, ask them to enable permission
}
}
}
If they have the permissions, I show them their avatar/username and some other options. If not, I present a link that asks them for the required permissions when clicked.
I'm running into a strange bug...
I'm asking for publish_actions permissions (I want to publish on the user's timeline the dive he just logged on diveboard.com ), and since I may want this to work in bulk (like publish all my dives) i want it done in the back and not through the front. I still want to request the permission on the front interactively.
When I ask only for "publish_actions", the popup opens and closes immediately and obviously the permission was not granted (checked in privacy)
FB.login(function(response) {
if (response.perms != undefined && response.perms.match(/publish\_actions/)!=null) {
G_user_fbtoken = getFBCookie().accessToken;
fbtimelinepublish_dive();
} else {
// user cancelled login
diveboard.notify("Unsufficient privileges","Could not get the adequate permissions to publish this action on your timeline");
toggle_fb_spinner();
return;
}
}, {scope:'publish_actions'});
}else{
fbtimelinepublish_dive();
}
Any clue !?
update : I tried with : scope:'create_event,publish_actions,publish_stream,rsvp_event'
and got
So I'm self-answering a solution : While in Open Graph Beta, the 'publish_actions' permission can only be requested from developers and test users of your app. The 'publish_actions' permission will be ignored if requested from any other user. and I moved to the new auth window.... hopefully this will save some frustrations to others....
I've written a facebook app, and I want to ask users for additional permission by this code:
function loadFanPages()
{
FB.login(
function(response) {
showFanpages();
}
, { scope : 'manage_pages' });
}
But I received a message from log:
FB.login() called when user is already connected.
How can I fix this error? At the first time user use this, I only ask permissions for "email,user_birthday,user_status,user_location"
That means the user is already logged in with those permissions granted. If you log out, or remove the permission via facebook, you should see the error disappears. You should make sure you only call that code when you need to so that users won't get this error.