0

我正在尝试将 Facebook 用户与 App42 链接,我可以登录到 facebook,这有效,但是我无法将用户与 app42 链接,我得到了一个例外。我正在使用以下代码:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    App42API.initialize(getApplicationContext(), "MY_API_KEY","MY_SECRET_KEY");
    FacebookSdk.sdkInitialize(getApplicationContext());
    callbackManager = CallbackManager.Factory.create();
    setContentView(R.layout.activity_main);
LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile", "user_friends"));
    loginButton = (LoginButton)findViewById(R.id.login_button);
    loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            Profile profile = Profile.getCurrentProfile();
            AccessToken token = AccessToken.getCurrentAccessToken();

            String userName = profile.getId();
            String accessToken = token.toString();
            socialService.linkUserFacebookAccount(userName, accessToken, new App42CallBack() {
                public void onSuccess(Object response) {
                    Social social = (Social) response;
                    System.out.println("userName is " + social.getUserName());
                    System.out.println("fb Access Token is " + social.getFacebookAccessToken());
                    String jsonResponse = social.toString();
                }

                public void onException(Exception ex) {
                    System.out.println("Exception Message" + ex.getMessage());
                }
            });

        }

        @Override
        public void onCancel() {

        }

        @Override
        public void onError(FacebookException e) {

        }
    });

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    callbackManager.onActivityResult(requestCode, resultCode, data);
}

我得到以下信息:

07-06 16:27:16.594    9810-9862/tk.hasankassem.tapo I/System.out﹕ (HTTPLog)-Static: isSBSettingEnabled false
07-06 16:27:16.954    9810-9810/tk.hasankassem.tapo I/System.out﹕ Installation.getSession : /data/data/tk.hasankassem.tapo/files/SESSION: open failed: ENOENT (No such file or directory)
07-06 16:27:16.954    9810-9810/tk.hasankassem.tapo I/System.out﹕ Installation.getUser : /data/data/tk.hasankassem.tapo/files/USER: open failed: ENOENT (No such file or directory)
07-06 16:27:16.964    9810-9868/tk.hasankassem.tapo I/System.out﹕ Exception :com.shephertz.app42.paas.sdk.android.App42Exception: java.lang.IllegalArgumentException: key.length == 0
07-06 16:27:16.964    9810-9868/tk.hasankassem.tapo I/System.out﹕ Exception Messagejava.lang.IllegalArgumentException: key.length == 0
07-06 16:27:16.969    9810-9867/tk.hasankassem.tapo I/System.out﹕ Thread-121146(ApacheHTTPLog):Reading from variable values from setDefaultValuesToVariables
07-06 16:27:16.969    9810-9867/tk.hasankassem.tapo I/System.out﹕ Thread-121146(ApacheHTTPLog):isSBSettingEnabled false
07-06 16:27:16.974    9810-9867/tk.hasankassem.tapo I/System.out﹕ Thread-121146(ApacheHTTPLog):isShipBuild true
07-06 16:27:16.974    9810-9867/tk.hasankassem.tapo I/System.out﹕ Thread-121146(ApacheHTTPLog):SmartBonding Enabling is false, SHIP_BUILD is true, log to file is false, DBG is false
4

1 回答 1

1

完成代码后,我想建议你

  1. 初始化 App42API 后创建 socialService 对象,如

App42API.initialize(getApplicationContext(), "MY_API_KEY","MY_SECRET_KEY"); SocialService socialService =App42API.buildSocialService();

  1. 如果您在初始化 SDK 之前创建 SocialService,则会出现以下异常。

Messagejava.lang.IllegalArgumentException: key.length == 0

于 2015-07-07T05:21:22.987 回答