从 QuickBlox 获取随机最终用户 [英] Getting random end user from QuickBlox
问题描述
我正在开发一款社交应用.对于当前用户,我需要随机显示该应用的其他用户.
I'm developing a social app. For current user, I need to randomly show other users of the app.
我首先想用这个代码来获取用户数:
I first want to use this code to get the number of users:
PagedRequest *request = [PagedRequest new];
request.perPage = 1;
request.page = 1;
[QBUsers usersWithPagedRequest:request delegate:self.proxy];
我注意到这是返回的 XML:
I noticed that this is the XML returned:
<users type="array" current_page="1" per_page="1" total_entries="13">
<user>
<blob-id type="integer" nil="true"/>
<created-at type="datetime">2013-07-24T06:16:13Z</created-at>
<email>xxxxxx@xx.com</email>
<external-user-id type="integer" nil="true"/>
<facebook-id nil="true"/>
<full-name>XXX xxx</full-name>
<id type="integer">236286</id>
<last-request-at type="datetime">2013-11-15T06:27:09Z</last-request-at>
<login>t2wu</login>
<owner-id type="integer">4282</owner-id>
<phone nil="true"/>
<twitter-id nil="true"/>
<updated-at type="datetime">2013-11-15T06:27:09Z</updated-at>
<website nil="true"/>
<user-tags nil="true"/>
</user>
</users>
我的意图是从total_entries=13"中得到13,所以我知道用户总数,然后再次发出这样的请求:
My intention is to get the 13 from the "total_entries=13", so I know that the total number of users, then make a request like this again:
PagedRequest *request = [PagedRequest new];
request.perPage = 1;
request.page = [self randomAmong: 13];
[QBUsers usersWithPagedRequest:request delegate:self.proxy];
where [self randomAmong: 13]
只需从 1 和 13 中选择一个数字,然后抓取用户的头像并显示给当前用户.
where [self randomAmong: 13]
just pick one number out of 1 and 13, then grab the user's profile picture and show it to the current user.
三个问题:
虽然我可以在控制台看到XML中的数字13输出,我不知道如何获得该数字.
Although I can see the number 13 in the XML in the console output, I have no idea how to get that number.
我只想轮流使用我的移动应用程序用户,而不是我的开发人员帐户(帐户用户).QuickBlox 允许多个应用程序与一个 QuickBlox 帐户用户相关联;然而,所有用户似乎被混为一谈.虽然我可以确定我只有此帐户内的一个应用程序,我仍然需要能够将自己排除在外.
I only want to rotate through my mobile application users, not my developer's account (the account user). QuickBlox allows multiple applications associated with one QuickBlox account user; however, all users seems to be lumped together. Although I could make sure that I only have one application inside this account, I still need to be able to exclude myself from it.
这是一个相对次要的问题.虽然上面获取当前用户数的尝试并没有尝试登录,委托方法-(void)completedWithResult:(Result*)result
将结果作为一个类QBUUserLogInResult
.我不明白这是为什么,为什么不是QBUUserPagedResult
或 QBUUserResult
似乎使更多感觉?
This is a relatively minor question.
Although the above attempt to get the current number of users is not
an attempt to log in, the delegate method
-(void)completedWithResult:(Result*)result
has result as a class
of QBUUserLogInResult
. I don't understand why it is, why isn't it
QBUUserPagedResult
or QBUUserResult
which seems to make more
sense?
谢谢.
推荐答案
这是一个正确的方法,以下是您问题的答案:
This is a right way, here are the answers for your questions:
1)
#pragma mark -
#pragma mark QBActionStatusDelegate
- (void)completedWithResult:(Result *)result{
// Get User result
if(result.success && [result isKindOfClass:[QBUUserPagedResult class]]){
QBUUserPagedResult *usersResult = (QBUUserPagedResult *)result;
int totalEntries = usersResult.totalEntries;
}
}
2)
您可以使用标签来分隔用户.在用户注册时 - 只需为此用户添加一个标签,例如app1".
You can use tags to separate users. While user sign up - just add a tag to this user, for example 'app1'.
下一步 - 检索带有标签app1"的用户 - 使用下一个查询:
Next - to retrieve users with tag 'app1' - use the next query:
[QBUsers usersWithTags:[NSArray arrayWithObjects:@"app1", nil] delegate:self];
3)
用户登录查询将返回'QBUUserLogInResult'结果
User login query will return 'QBUUserLogInResult' result
获取单用户查询将返回'QBUUserResult'结果
Get single user query will return 'QBUUserResult' result
获取多个用户查询将返回'QBUUserPagedResult'结果
Get multiple users query will return 'QBUUserPagedResult' result
这篇关于从 QuickBlox 获取随机最终用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!