ParsefacebookUtils在Parse中返回错误的值

时间:2015-08-20 09:05:58

标签: android parse-platform facebook-sdk-4.0 parsefacebookutils

对于我的Android应用程序我想整合一个facebook登录,所以我完全按照这里做的:
https://github.com/ParsePlatform/IntegratingFacebookTutorial

一切似乎工作正常但是存储在解析后端中的值不方便,这是例如我用我的facebook帐户登录后得到的: emailVerified:空
用户名:adGdJMxcCQCAo2 .....
authData:{“facebook”:{“access_token”:“CAAMBDxU3HgUBAMYQ8q2mnjDqeKBz2sw ......”,“expiration_date”:“...”,“id”:“1015353 ...”}}

对不起我还是无法上传图片.. 这是正常的吗?

我正在使用parseFacebookUtils 1.9.4 解析1.9.4

1 个答案:

答案 0 :(得分:0)

这是我为facebook parse.com登录

所做的

<强> LoginFragment.java

private ParseLoginConfig config;

@Override
public View onCreateView(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState, 1);
    rootView = inflater.inflate(R.layout.layout_login, container, false);
    config = ParseLoginConfig.fromBundle(getArguments(), getActivity());
    return rootView;
}

private void loginUsingFacebook() {
    // TODO Auto-generated method stub
    if (config.isFacebookLoginNeedPublishPermissions()) {

        ParseFacebookUtils.logInWithPublishPermissionsInBackground(
                getActivity(), Arrays.asList("public_profile", "email"),
                facebookLoginCallbackV4);
    } else {
        ParseFacebookUtils.logInWithReadPermissionsInBackground(
                getActivity(), Arrays.asList("public_profile", "email"),
                facebookLoginCallbackV4);
    }
}


private LogInCallback facebookLoginCallbackV4 = new LogInCallback() {
    @Override
    public void done(ParseUser user, ParseException e) {
        if (isActivityDestroyed()) {
            return;
        }

        if (user == null) {
            loadingFinish();
            if (e != null) {
                showToast(R.string.com_parse_ui_facebook_login_failed_toast);
                debugLog(getString(R.string.com_parse_ui_login_warning_facebook_login_failed)
                        + e.toString());
            }
        } else if (user.isNew()) {
            GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(),
                    new GraphRequest.GraphJSONObjectCallback() {
                        @Override
                        public void onCompleted(JSONObject fbUser,
                                GraphResponse response) {
                            /*
                             * If we were able to successfully retrieve the
                             * Facebook user's name, let's set it on the
                             * fullName field.
                             */
                            Log.e("facebook User", fbUser.toString());
                            final ParseUser parseUser = ParseUser
                                    .getCurrentUser();
                            if (fbUser != null
                                    && parseUser != null
                                    && fbUser.optString("name").length() > 0) {
                                parseUser.put(USER_OBJECT_NAME_FIELD,
                                        fbUser.optString("name"));
                                parseUser.put(USER_OBJECT_EMAIL_FIELD,
                                        fbUser.optString("email"));
                                parseUser
                                        .saveInBackground(new SaveCallback() {
                                            @Override
                                            public void done(
                                                    ParseException e) {
                                                if (e != null) {
                                                    debugLog(getString(R.string.com_parse_ui_login_warning_facebook_login_user_update_failed)
                                                            + e.toString());
                                                }
                                                ParseInstallation installation = ParseInstallation
                                                        .getCurrentInstallation();
                                                installation
                                                        .put(BaseFragment.INSTALLATION_UNIQUE_ID,
                                                                parseUser
                                                                        .getUsername());
                                                installation
                                                        .saveInBackground();
                                                loginSuccess();
                                            }
                                        });
                            }
                        }
                    }).executeAsync();
        } 
    }
};

注意: 删除举报邮件,并在有任何疑问时给我发短信!!