通过user_link打开用户Facebook页面时出现问题

问题描述:

尝试打开用户的Facebook页面时,我收到错误消息.如果我与该用户有一个共同的朋友,则该页面加载不会有问题,但是我认为这不是默认行为,否则我将无法理解user_link权限的含义.

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已批准user_link权限,并且我通过了应用审核.

Facebook has approved user_link permission and I passed App Review.

从开发者帐户中,我将应用程序调用的API版本更改为v3.1.

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

我的获取方式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();
    }

并使用答案打开页面.

  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'

如果有人可以提出任何解决方案,我将非常感激.在Facebook新API版本发布之前,我也遇到了这个问题.

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

来自

From this post we can find the following bit of text

对于大多数应用程序,链接只会重定向到个人的Facebook 个人扩展网络中已登录用户的个人资料.

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

因此,我想没有办法100%确定用户页面将被正确加载.

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