2015-02-09 55 views
0

我正在使用quickblox聊天api进行群聊。我正在使用用户名和密码创建聊天会话。 这是我的聊天聊天室的代码。如何使用电子邮件和密码在quickblox中创建聊天会话

final QBUser user = new QBUser(); 
     user.setLogin(username); 
     user.setPassword(password); 

     QBAuth.createSession(user, new QBEntityCallbackImpl<QBSession>() { 
      @Override 
      public void onSuccess(QBSession session, Bundle args) { 

       System.out.println("user id " + session.getUserId()); 

       user.setId(session.getUserId()); 
       ((ApplicationSingleton) getParent().getApplication() 
         .getApplicationContext()).setCurrentUser(user); 

       loginToChat(user); 

      } 

      @Override 
      public void onError(List<String> errors) { 

       editor.putBoolean("ISCHECKED", false); 
       editor.putString("Username", ""); 
       editor.putString("Password", ""); 
       editor.commit(); 

       AlertDialog.Builder dialog = new AlertDialog.Builder(
         getParent()); 
       dialog.setMessage("create session errors: " + errors).create() 
         .show(); 
       pDialog.dismiss(); 
      } 
     }); 

但我想使用电子邮件和密码创建会话。 任何人有任何想法做到这一点。

回答

2

相同,但设置一个电子邮件,而不是登录

final QBUser user = new QBUser(); 
user.setEmail(email); 
user.setPassword(password); 
+0

我都试过,但它并没有工作我得到像“{‘错误’错误:{‘基地’:‘意外的签名’ ]}}” – 2015-02-09 10:29:31

+0

请张贴您的logcat – 2015-02-09 10:56:41

+0

***回覆*** d5f0de73-88d8-4a00-b91c-b181fe0a3fab *** 状态日志:422个 HEADERS 访问控制允许来源= * 的cache Control = no-cache Connection = keep-alive Content-Type = application/json; Charset = utf-8 Date = Mon,09 Feb 2015 11:19:03 GMT QuickBlox-REST-API-Version = 0.1.1 Server = nginx/1.0.15 Status = 422 Unprocessable Entity Transfer-Encoding =分块 X-机架缓存=无效,通过 X - 请求-ID = 4c3518b5fb6dd6b7a7346b0f2b57c877 X-运行时间= 0.006692 X-UA-兼容= IE =边沿,铬= 1个 BODY “{ “错误”:{”基地“:[”意外的签名“]}}' – 2015-02-09 11:21:58

相关问题