Not able to post to Facebook using custom-ui project of socialauth-android project - facebook

I am not able to post Facebook using the custom-ui project of socialauth-android.
Here is the error log.
10-31 13:18:05.124: D/SocialAuthError(21880): org.brickred.socialauth.exception.SocialAuthException: org.brickred.socialauth.exception.SocialAuthException: Status not updated. Return Status code :403
10-31 13:18:05.124: W/System.err(21880): org.brickred.socialauth.android.SocialAuthError: Message Not Posted
10-31 13:18:05.124: W/System.err(21880): at org.brickred.socialauth.android.SocialAuthAdapter$6.run(SocialAuthAdapter.java:868)
10-31 13:18:05.124: W/System.err(21880): at java.lang.Thread.run(Thread.java:818)
I am not able to find the issue. I am using the same API keys got from the Github source.

You are getting 403 Authentication Error that clearly means that your app is presently not authorized to publish on Facebook profile of the user.
There is some problem the way you are trying to use Facebook APIs. I would suggest you to the latest Facebook SDK for Android as some of the older methods may be deprecated. Let me tell you the approach for doing this right way. (I recently implemented latest Facebook SDK)
You need a permission
There are some specific permissions that you require to do some specific operations with Facebook SDK. For example, You need publish_actions permission if you want your app to post status on user's profile.
Check Out It says,
For example, the publish_actions permission lets you post to a person's Facebook Timeline.
How to get Permissions
You need to show the user a login button which will ask him to do login with his facebook account and notifying the user what your app may do with his Facebook profile. It will show the permissions. In your case you need to add a login button with publish_actions permission. Once the user accepts it, your app becomes authorized to post status.
Complete Tutorial is here for doing the login process of Facebook with permissions.
You will need to do the following,
LoginButton authButton = (LoginButton) view.findViewById(R.id.authButton);
authButton.setFragment(this);
authButton.setReadPermissions(Arrays.asList("user_likes", "user_status", "publish_actions"));
return view;
So you can see we are asking the user to give you the publish_actions permission. It is not mandatory to include user_likes or user_status permissions. You can remove them if you don't need them.
Next what after login
After the user logs in, you get an authentication token in your session with Facebook. So now you can use that to publish on user's profile.
How to post
Now there are many ways to publish posts or status on Facebook. The first one I would like to discuss is using the Graph API
Here is somewhat code, you can use to publish to facebook.
Session session = Session.getActiveSession();
new Request(
session,
"/me/feed",
null,
HttpMethod.POST,
new Request.Callback() {
public void onCompleted(Response response) {
}
}
).executeAsync();
NOTE
You do also need to create developer account with facebook and add your app to its dashboard, generate an app_id and mention the same in your AndroidManifest.xml file.

Related

How to request pages_show_list permission with Facebook Graph API?

I tried 2 way, one in the Facebook Developer site find permission request with this name, I couldn't find it.
add as a 4th parameter to the Facebook Login Button, it did not help
<FacebookLogin
appId={fbAppId}
autoLoad={true}
fields="name,email,picture,pages_show_list"
onClick={this.componentClicked}
callback={this.responseFacebook}
/>
Do you have any other idea?
The Facebook API works like this,
Development Mode: For development mode you can try to access pages which were associated with the account in which app created. So, that pages associated with that user can be accessible. You can retrieve the pages using following link,
https://developers.facebook.com/docs/graph-api/reference/user/accounts/
Live mode: In case of live mode you need to create a video of snapshot using your development mode functionality and get "pages_show_list" permission approved. Then you can access the pages details associated with authenticated users.
For login button you can try like this,
fb:login-button size="large" scope="public_profile,email,pages_show_list,read_insights,manage_pages" onlogin="checkLoginState();"
which gives you token and use that token to get pages associated with user account.
If you are using the js SDK of Facebook then there is an option to ask permission through SDK functions.
FB.login(function(response) {
// handle the response
}, {scope: 'public_profile,email,..other persmissionlist'});
Note:-
Use this concept only when your app is in the testing phase and
wants to create a request for permission in App Review or there are
some permissions enabled but you want only a few.
Use this approach with Test users only.
Reference link:-
https://developers.facebook.com/docs/facebook-login/web#re-asking-declined-permissions

How to create feed using admin account without submit app - Graph API

I'm trying to publish a feed. I receive an error
The permission(s) manage_pages,publish_pages are not available. It could because either they are deprecated or need to be approved by App Review.
After I take a look at their example for app review, I see this.
In my understanding, I think this mean I do not need for a app review if I use admin user access token. Correct me if I am wrong.
As I am the only one who will publish feed on my page, I try to set the access token to my admin account access token. But, I receive another error
(#200) Unpublished posts must be posted to a page as the page itself.
Is that mean the only way I can do is to submit app review?

Get user profile link from Facebook's Graph API

I have an app-scoped user id (ASUID) for a Facebook user and I wish to obtain a link to that user's profile page.
A post on Facebook's Developer blog dated May 1, 2018 states that this link is accessible as of Graph API v3.0 through the link field on a user object. Access to this field requires the user_link permission be approved for the app and granted by the app user.
I have attempted to access this field with a user access token associated with my test app and I have verified the access token has the user_link permission granted via the Access Token Debugger. However, the link is not included in the response.
Request:
https://graph.facebook.com/v3.0/[ASUID]?fields=link&access_token=[ACCESS_TOKEN_W_USER_LINK_PERMISSION]
Response:
{ "id": "[ASUID]" }
Is there any indication as to why this is not working?
As documented, the user_link permission requires an App Review pass before it's available to live apps.
At time of writing this answer there is no way to get user profile page using Facebook API.

Do review required if we want to get Facebook Page like count (Without Facebook login) by Facebook app token?

I am doing a static web page in my website, in which I am showing the like count of particular Facebook page. There is no kind of login required to see this web page. Also, I don't want to user to login with their Facebook account to see the Facebook page like count.
I have implemented this requirement by using Facebook app token.
API: "https://graph.facebook.com/PAGE_ID?access_token=APP_TOKEN"
But the problem here is, If I use the app token of already approved app by Facebook with some permissions (manage_pages) exists, it works. It is not working for the app token of newly created Facebook app.
I have sent the app for review to Facebook by requesting manage_pages permission, but they rejected the app and said that my website doesn't have the Facebook login functionality implemented.
Since it is not documented clearly, I have a doubt that do the app need to send for review if I want to get the Facebook page like count without Facebook login (By using Facebook app token)? If yes, what permission do I want to request?
Any help would be much appreciated.
First of all, you need to learn what Tokens there are:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/
For your problem, you can just use an App Access Token. There is no need for any permission or Login Review, the links above tell you exactly how to create one. Make sure you never use the Token on the client, especially because it includes the App Secret. Do the API call on the server only (file_get_contents or curl, if you use PHP).
If by "it does not work" you mean that you only get the id and the name, then it´s not about "not working", you need to read the changelog and search for "Declarative Fields": https://developers.facebook.com/docs/apps/changelog#v2_4
So if you want to get more than just id and name, the API call would be like this: https://graph.facebook.com/936299239766048?access_token=YOURAPPTOKEN&fields=id,name,likes,...

Graph API v2.2 : user_status permission is obtained from facebook but still cant get the v2.2/me?fields=statuses data

I have an app & user_status permission is obtained from facebook after its submitted for review. I can get the v2.2/me?fields=statuses data for the App's admin. No other fb accounts are able to get this data. When I login with facebook from my portal, the permissions requested are not shown to the users.
Is the issue related to FB API. I can use the obtained permissions only for the App's admin alone?
Is this issue related to not obtaining consent from the account while logging in from my portal. If yes, what is the method to get this done.
Anyone kindly help me regarding this.
It's all in the docs:
https://developers.facebook.com/docs/apps/review/login#do-you-need-review
...your app's developers will be able to see, and grant, any permission without requiring review by Facebook.
and
People who are listed in your app's Roles tab will have access to extended permissions without going through review (e.g. publish_actions or manage_pages). For example, if you use the Facebook Plugin for Wordpress to publish your blog posts to your Facebook Page or Profile, you do not need to submit for review so long as all your publishers are listed in your app's Roles tab.