Twitter帐户始终返回空白时间线?

时间:2014-01-22 23:57:13

标签: ios twitter timeline

我最近开始了一个Xcode项目,它要求我从Twitter帐户获取Feed或时间轴。我关注this tutorial。虽然当我编译我的代码时,它没有错误,但它不会记录任何推文。我还下载了该项目的源代码,但它仍然没有返回任何内容。我意识到这可能是我帐户中的一个问题,但我最近发了一些推文,跟随一些人,转发了,基本上你可以做的所有事情来更新时间表!谢谢您的帮助! 推特账号:@Pushahk

-(void)getTwitterFeed{
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[account requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error){
    if (granted == YES) {
        NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
        if ([arrayOfAccounts count] > 0) {
            ACAccount *twitterAccount = [arrayOfAccounts lastObject];
            NSURL *requestAPI = [NSURL URLWithString:@"http://api.twitter.com/1.1/statuses/user_timeline.json"];
            NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
            [parameters setObject:@"100" forKey:@"count"];
            [parameters setObject:@"1" forKey:@"include_entities"];
            SLRequest *posts = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:requestAPI parameters:parameters];
            posts.account = twitterAccount;
            [posts performRequestWithHandler:
            ^(NSData *response, NSHTTPURLResponse
                                              *urlResponse, NSError *error)
            {

                // The NSJSONSerialization class is then used to parse the data returned and assign it to our array.

                self.TwitterPosts = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];

                    dispatch_async(dispatch_get_main_queue(), ^{
                        NSLog(@"Hi");
                        for (int i = 0; i < [self.TwitterPosts count]; i++) {
                            NSLog(@"%@", [self.TwitterPosts objectAtIndex:i]);
                            NSLog(@"Hi");
                        }

                    });


            }];
        }
    }
    else{
        NSLog(@"%@", [error localizedDescription]);
    }
}];

}

1 个答案:

答案 0 :(得分:1)

这是因为include_entities不再是v1.1 API中的有效参数(它位于v1 API中)。您可能还需要提供一个屏幕名称,因为我认为在请求中设置.account属性仅用于OAuth目的。

来源:http://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline