0

我正在使用 TWRequest 来查询推特。我想知道如何在 URL 末尾添加 +exclude:retweets 过滤器。这是我的代码:

NSString *searchURL = [NSString stringWithFormat:@"http://search.twitter.com/search.json"];
        NSMutableDictionary *dict_req;

dict_req = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"50", @"rpp", @"true", @"include_entities", searchParams, @"q", nil];

TWRequest *request = [[TWRequest alloc] initWithURL:[NSURL URLWithString:searchURL]
                                                      parameters:dict_req requestMethod:TWRequestMethodGET];

[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
     {
      //results
    }];
4

1 回答 1

0

第一个工作解决方案:使用 nil 作为参数字典并手动将参数添加到 searchURL。不幸的是,它似乎不适用于复杂的查询......

NSString *searchURL = [NSString stringWithFormat:@"http://search.twitter.com/search.json?q=ciao+exclude:retweets"];

TWRequest *request = [[TWRequest alloc] initWithURL:[NSURL URLWithString:searchURL] 参数:nil requestMethod:TWRequestMethodGET];

于 2012-07-04T11:25:22.933 回答