我有一个聊天应用,我想要检索两个用户之间的聊天记录,我有一个用于检索聊天消息的节,那就是......
<iq type='get' id='pk1'>
<list xmlns='urn:xmpp:archive'
with='shrey27@sys1-pc'>
<set xmlns='http://jabber.org/protocol/rsm'>
<max>30</max>
</set>
</list>
</iq>
现在,我的问题是如何将此节点发送到服务器以便我可以获得响应。我已经安装了消息存档插件并且消息正在完美存储。任何建议都将是有益的... 提前致谢!!!
答案 0 :(得分:4)
NSXMLElement *iQ = [NSXMLElement elementWithName:@"iq"];
[iQ addAttributeWithName:@"type" stringValue:@"get"];
[iQ addAttributeWithName:@"id" stringValue:@"987654321"];
NSXMLElement *list = [NSXMLElement elementWithName:@"list"];
[list addAttributeWithName:@"xmlns" stringValue:@"urn:xmpp:archive"];
[list addAttributeWithName:@"with" stringValue:@"bhushan@mydomain.com"];
NSXMLElement *set = [NSXMLElement elementWithName:@"set"];
[set addAttributeWithName:@"xmlns" stringValue:@"http://jabber.org/protocol/rsm"];
NSXMLElement *max = [NSXMLElement elementWithName:@"max"];
[max addAttributeWithName:@"xmlns" stringValue:@"http://jabber.org/protocol/rsm"];
max.stringValue = @"30";
[set addChild:max];
[list addChild:set];
[iQ addChild:list];
[[[self appDelegate] xmppStream] sendElement:iQ];
你可以这样打电话。希望这会有所帮助:)