Get user profile link from Facebook's Graph API - facebook

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.

Related

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

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.

Unable to get Facebook user age_range

I have a portal which has the following functionality to comment on FaceBook posts:
1. When a user chooses to a comment on a post, FB credentials of that specific user are requested.
2. When that user signs in with FB credentials my FB app asks for public profile permission.
3.When I use the access token of the same app in the graph explorer it does not return me the age_range of the users (irrespective of whether they are logged in or logged out of FB) who have approved/not approved my app.
4. I have checked for the public_profile permission even on the access token as well, using the debug feature in graph explorer but still I'm not getting the age_range.
Can anyone tell me step by step procedure to get the age_range of a user?

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.

Facebook: Get access token to post as a page

Is it possible to somehow get an access token to use the facebook api like a user that clicked "use facebook as "?
What I'm trying to do is to allow my website to post messages to the facebook page's wall. I already have an app which I use to allow my users to login with their FB account. However, I'd prefer not to require a page admin to authorize full manage_pages to my app. I already added the app to my FB page, but there are no options to give that app some permissions for my page.
Of course it's possible.
In the official documentation page about Permissions it's written:
Page access_token
An access_token used to manage a page. This is used
when you want to perform an operation acting as a Page. This access
token is retrieved by issuing an HTTP GET to /USER_ID/accounts or to
/PAGE_ID?fields=access_token with the manage_pages permission. Getting
/USER_ID/accounts will return a list of Pages (including app profile
pages) to which the user has administrative access in addition to an
access_token for each Page. Alternatively, you can get a page access
token for a single, specific, page by issuing an HTTP GET to
/PAGE_ID?fields=access_token with the manage_pages permission (you
must ask for the access_token field specifically via the fields=
parameter). See the documentation for the Page object for more
information. NOTE: After November 1, 2011, manage_pages permission
will be required for all access to a user's pages via this connection,
i.e. for both reading the user's pages and also retrieving
access_tokens for those pages. See the documentation for the User
object for more information.

iOS post to the Facebook app wall

I am wondering if it is possible to post to the wall of the Facebook app page created for using Facebook in iOS. Rather than use the user login to post to their own wall, I would like to post to the app's page with updates on open games. Is this possible to do?
Yes, it's possible. From http://developers.facebook.com/docs/reference/api/application/:
To perform the following operations as an Application Page, and not the current user, you must use the Application's Page access token, not the user access token commonly used for modifying Graph API objects nor the Application access token. This access token can be retrieved by issuing an HTTP GET to /USER_ID/accounts with the manage_pages permission. This will return a list of Pages (including Application profile pages) to which the user has administrative access, along with an access_token for each Page.
…
You can create a link, post or status message by issuing an HTTP POST request to the APP_ID/feed connection. To see more details please see links, posts, and status messages documentation.
To impersonate the Application when posting to the wall (i.e. post as the Application, and not the current user), you must use an Application Page access_token with the manage_pages and publish_stream permissions, as described under Application Access Tokens above.
So you first have to ask the API for an Application Page access token and then use this access token to post on the wall. The Facebook iOS SDK helps to construct the Graph API calls mentioned in the documentation cited above.