【问题标题】:Saving QuickBlox chat history using JS使用 JS 保存 QuickBlox 聊天记录
【发布时间】:2015-02-04 23:37:17
【问题描述】:

我尝试使用 JS 在服务器端保存聊天记录。没有运气。

根据 SDK 我需要使用扩展名:{save_to_history: 1}

但我不明白在哪里使用它,所以 XML 请求是正确的。

这是来自 JS 聊天示例的代码:

message = {
            message: post,
            name: chatUser.name,
            avatar: chatUser.avatar,
            fb: chatUser.fbID
        };
        message = Strophe.escapeNode(JSON.stringify(message));

        if (userJID) {
            params = {
                to: userJID,
                from: connection.jid,
                type: 'chat'
            };
            connection.send($msg(params).c('body').t(message));

请指教!

【问题讨论】:

  • 您好,我确实尝试将 save_to_history: 1 添加到 message{} 和 params {} - 结果相同,XML 请求以某种方式显示“save_to_history”,已修改,可能是因为一些序列化。并且不要保存任何东西。

标签: javascript xml chat history quickblox


【解决方案1】:

下载最新版JS SDK: http://quickblox.com/developers/Javascript

阅读代码sn-ps: http://quickblox.com/developers/Web_XMPP_Chat_Sample#Chat_2.0_API_instead_the_chat_plugin

接下来,使用这个:

QB.chat.send(userJID, {type: 'chat', body: post, extension: {
  save_to_history: 1,
  name: chatUser.name,
  avatar: chatUser.avatar,
  fb: chatUser.fbID
}});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-29
    • 1970-01-01
    • 2021-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-25
    相关资源
    最近更新 更多