1

想要在已经创建的 QuickBlox 自定义表中创建新记录。我有遵循指南网址并使用以下方法,这里我使用我的表名

HashMap<String, Object> fields = new HashMap<String, Object>();

    fields.put("User ID",String.valueOf(myID));
    fields.put("senderLoginID", ""+mylogin.toString());
    fields.put("receiverLoginID", ""+friendLogin.toString());
    fields.put("messages", messageString);

    fields.put("isRead", false);


QBCustomObject qbCustomObject = new QBCustomObject();
qbCustomObject.setClassName("Movie");  // your Class name
qbCustomObject.setFields(fields);
QBCustomObjects.createObject(qbCustomObject, new QBCallbackImpl() {
    @Override
    public void onComplete(Result result) {
        if (result.isSuccess()) {
            QBCustomObjectResult qbCustomObjectResult = (QBCustomObjectResult) result;
            QBCustomObject qbCustomObject = qbCustomObjectResult.getCustomObject();
            Log.d("New record: ",newCustomObject.toString());
        } else {
            Log.e("Errors",result.getErrors().toString());
        }
    }
});

得到喜欢时出错

** '{"errors":{"base":["Forbidden. Need user."]}}'
… Request has been completed with error: [base Forbidden. Need user.]
4

1 回答 1

1

第一关,你不需要使用这个

fields.put("User ID",String.valueOf(myID));

此字段将根据您的令牌信息在服务器上填写

接下来,您必须登录才能创建记录,只需执行下一个

http://quickblox.com/developers/SimpleSample-users-android#Sign_In_.26_Social_authorization

于 2013-10-30T19:42:44.017 回答