NSString *url = [NSString stringWithFormat:@"http://api.twitter.com/1.1/search/tweets.json?q=%@&result_type=recent&count=%i", toBeSearched, count];
url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
SLRequest *twitterInfoRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:[NSURL URLWithString:url] parameters:nil];
[twitterInfoRequest setAccount:twitterAccount];
[twitterInfoRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
if ([urlResponse statusCode] == 429) {
//Rate Limit Reached
} else if (error) {
// Check if there was an error
}
// Check if there is some response data
if (responseData) {
NSError *error = nil;
NSArray *result = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&error];
// Do Whatever you want to do, the result is an array of 'tweet objects'
}
}];
啊,我想我只是得到某種URL作爲迴應,但它看起來像你根據我的歷史猜測了Objective-C? 雖然我從代碼中收集URL,但我正在嘗試使用它。所以你說的東西像'http://api.twitter.com/1.1/search/tweets.json?q = ABC&result_type = recent&count = 10' – muttley91
你可以通過URL傳遞更多參數:https:/ /dev.twitter.com/docs/api/1/get/search –
哦。我以爲你問它的iOS。那麼,該網址就是您在代碼中找到的網址。 –