issue while opening user facebook page by user_link

不羁岁月 提交于 2020-01-13 03:19:05

问题


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.


回答1:


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.




回答2:


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)



来源:https://stackoverflow.com/questions/51658999/issue-while-opening-user-facebook-page-by-user-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!