iphone - MGTwitterEngine 检查是否关注用户

标签 iphone ios twitter mgtwitterengine

我在我的 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/

相关文章:

C++,序列模式下二进制文件的问题

php - 读取 Twitter cookie?

ios - 替换 html 字符串中的特定单词

ios - 在 UIStackView 中缩放 UIImage 的图像以适应 iOS 应用程序中的屏幕大小

ios - Singleton 的 Swift Delegate 不工作

perl - 我如何使用 Perl 更新我的 Twitter 状态并且只使用 LWP::UserAgent?

python - App Engine - 难以访问 Twitter 数据 - Flask

iphone - 当 UIView 添加到它的父 View 时,它如何获得回调?

iphone - 如何在viewDidLoad中加载 View ?

iphone - UIImage 第一次加载时卡顿