IOS获得Twitter目前的最佳趋势

时间:2014-05-23 20:20:23

标签: ios twitter

我想获得Twitter目前的趋势。我累了https://dev.twitter.com/docs/api/get-trendscurrent,但没有数据没来。我的代码在这里:

-(void) getTwitterTopTrends{

    // 1. Create a variable for twitter
    NSURL *feedURL = [NSURL URLWithString:@"http://api.twitter.com/1/trends/current.json"];

    // 2. Create TWRequest, with parameters, URL & specify GET method
    SLRequest *twitterFeed = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:feedURL parameters:nil];
    twitterFeed.account = _twitterAccount;
    // Making the request
    [twitterFeed performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
        dispatch_async(dispatch_get_main_queue(), ^{
            // Check if we reached the reate limit
            if (responseData) {

                NSError *error = nil;
                NSDictionary *TWData = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&error];
                NSArray* results = TWData [@"trends"];
            }
        });
    }];
}

我错了。

1 个答案:

答案 0 :(得分:2)

API版本1逐步淘汰。在此处尝试1.1版:https://dev.twitter.com/docs/api/1.1/overview