ParsefacebookUtils在解析返回错误的值 [英] ParsefacebookUtils returning wrong values in Parse

查看:241
本文介绍了ParsefacebookUtils在解析返回错误的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Andr​​oid应用我想整合Facebook登录,所以我做了什么是在这里:结果
https://github.com/ParsePlatform/IntegratingFacebookTutorial

for my android application i wanted to integrate a facebook login, so i did exactly what is here:
https://github.com/ParsePlatform/IntegratingFacebookTutorial

一切似乎很好地工作但其存储在后端解析的值都不方便,这里是什么样的例子我和我的Facebook帐户登录后得到:
emailVerified:空结果
用户名:adGdJMxcCQCAo2 .....结果
的authData: {\"facebook\":{\"access_token\":\"CAAMBDxU3HgUBAMYQ8q2mnjDqeKBz2sw......\",\"expiration_date\":\"...\",\"id\":\"1015353...\"}}

Everything seems to work fine however the values which are stored in the parse backend are not convenient, here is for example what i get after login with my facebook account: emailVerified:empty
username:adGdJMxcCQCAo2.....
authData: {"facebook":{"access_token":"CAAMBDxU3HgUBAMYQ8q2mnjDqeKBz2sw......","expiration_date":"...","id":"1015353..."}}

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

Sorry i still can't upload pictures.. Is this normal?

我使用parseFacebookUtils 1.9.4
解析1.9.4

i'm using parseFacebookUtils 1.9.4 parse 1.9.4

推荐答案

这是我所所做的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();
        } 
    }
};

注意: 删除敬酒消息,如果有任何查询文本我!

这篇关于ParsefacebookUtils在解析返回错误的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆