gpt4 book ai didi

iphone - MGTwitterEngine 检查是否关注用户

转载 作者:行者123 更新时间:2023-11-29 04:12:03 25 4
gpt4 key购买 nike

我在我的 iOS 应用程序中使用 MGTwitterEngine SDK。我正在尝试使用此方法检查用户是否正在关注另一个用户:

- (NSString *)isUser:(NSString *)username1 receivingUpdatesFor:(NSString *)username2
{
if (!username1 || !username2) {
return nil;
}
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:0];
[params setObject:username1 forKey:@"user_a"];
[params setObject:username2 forKey:@"user_b"];

NSString *path = [NSString stringWithFormat:@"friendships/exists.%@", API_FORMAT];

return [self _sendRequestWithMethod:nil path:path queryParameters:params body:nil
requestType:MGTwitterUpdatesCheckRequest
responseType:MGTwitterMiscellaneous];
}

此方法始终返回采用此格式但不相同的字符串:

CB4C097E-6740-4536-885E-BAF7D8A981FD

基本上,获得一个 bool 值会更好,我不知道要如何处理这个值。

有什么想法吗?

**编辑初始化_engine的代码

        _engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate: self];
_engine.consumerKey = kOAuthConsumerKey;
_engine.consumerSecret = kOAuthConsumerSecret;

最佳答案

这是一个异步请求,您必须将您的类设置为 MGTwitterEngine 的委托(delegate)并在这些方法中获取结果,您必须在您的类中实现这些方法:

- (void)statusesReceived:(NSArray *)statuses forRequest:(NSString *)connectionIdentifier;
- (void)directMessagesReceived:(NSArray *)messages forRequest:(NSString *)connectionIdentifier;
- (void)userInfoReceived:(NSArray *)userInfo forRequest:(NSString *)connectionIdentifier;
- (void)miscInfoReceived:(NSArray *)miscInfo forRequest:(NSString *)connectionIdentifier;

正如您在 MGTwitterEngineDelegate.h 中所读到的:

// These delegate methods are called after all results are parsed from the connection. If 
// the deliveryOption is configured for MGTwitterEngineDeliveryAllResults (the default), a
// collection of all results is also returned.

您可以在此处检查结果值。

关于iphone - MGTwitterEngine 检查是否关注用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14259815/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com