5

I am getting this error message while trying to open the facebook page of the user.The strange thing is that if I have a mutual friend with that user the page loads with no problem, but I don't think it's default behavior, otherwise I can't understand the meaning of user_link permission.

Facebook has approved user_link permission and I passed App Review.

From developer account I changed the API version the app calls to v3.1.

The way I am getting user_link

LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("user_gender", "user_link"));
        LoginManager.getInstance().registerCallback(callbackManager,
                new FacebookCallback<LoginResult>() {
                    @Override
                    public void onSuccess(LoginResult loginResult) {
                       makeGraphRequest(loginResult.getAccessToken());
                    }

                    @Override
                    public void onCancel() {
                    }

                    @Override
                    public void onError(FacebookException error) {

                    }
                });


 public void makeGraphRequest(AccessToken token) {
        GraphRequest request = GraphRequest.newMeRequest(
                token, (object, response) -> {
                    try {
                        userStorage.setUserProfileUrl(object.getString(AppConstants.LINK));
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                });
        Bundle parameters = new Bundle();
        parameters.putString("fields", "name,gender,link,picture.width(700).height(700)");
        request.setParameters(parameters);
        request.executeAsync();
    }

And using this answer for opening the page.

  Intent intent;
                try {
                    context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
                    intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://facewebmodal/f?href=" + currentUser.getLink()));
                    context.startActivity(intent);
                } catch (Exception e) {
                    intent = new Intent(context, FacebookWebViewActivity.class);
                    intent.putExtra(AppConstants.USER_LINK, currentUser.getLink());
                    context.startActivity(intent);
                }

build.gradle

implementation 'com.facebook.android:facebook-login:4.33.0'

I will be very thankful if someone can suggest any solution. I faced this issue before the facebook new API version also.

Levon Petrosyan
  • 8,815
  • 8
  • 54
  • 65
  • @ Levon Petroysen , i have valid use case for user _ link but apart from my profile i can not open the profile of other as my app review is pending. I have created test app so that i can use user_link permission and i am receiving user_link properly but i want to show profile to other friend in my app but when i try to open my friends url which link return its giving link broken error. – Janardhan R Aug 01 '19 at 11:25

2 Answers2

3

From this post we can find the following bit of text

For most apps, links will only redirect to the individual's Facebook profile for logged in people in the person's extended network.

So, I guess there is no way to be 100% sure that the user page will be loaded properly.

Levon Petrosyan
  • 8,815
  • 8
  • 54
  • 65
  • I am struggling with the same issue now. What is "Extended network"? What does it mean no way to be 100% sure? It's programming, stuff needs to be 100% accurate, what kind of API is that then :) Moreover, when users cannot access they just get a PAGE NOT FOUND, not some explanation or anything. This makes our website look buggy.. – Vladi Jan 25 '21 at 12:20
1

https://developers.facebook.com/docs/graph-api/changelog/version3.0#login

...the following fields that belonged to public_profile are deprecated...

As you can read in the changelog, the "link" and "gender" fields are deprecated.

Edit: But they have introduced new permissions user_link and user_gender so that users can explicitly asked for those particular fields. (Thanks to CBroe for pointing that out)

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • 2
    That is a bit of unlucky phrasing in the changelog, I think - they are “deprecated” as being part of what `public_profile` gives you access to. But they have introduced new permissions [`user_link`](https://developers.facebook.com/docs/facebook-login/permissions/v3.0#reference-user_link) and `user_gender` so that users can explicitly asked for those particular fields. – CBroe Jun 13 '18 at 06:58
  • did you try with the latest api version? btw, in the api reference, it still says "link", so maybe just the permission is called "user_link", and the field is still the same? earlier, there was no separate permission for it. – andyrandy Jun 15 '18 at 05:44