Question

I have recently begun an Xcode project, and it requires me to get the feed, or timeline, from a Twitter account. I am following this tutorial. Although when I compile my code, it has no errors, it does not log any tweets. I also downloaded the source code for the project, but it still returns nothing. I realize that it could be a problem from my account, but I have tweeted something recently, followed some people, retweeted, basically everything you could do to update a timeline! Thanks for the help! Twitter Account:@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]);
    }
}];

}
Was it helpful?

Solution

It's because include_entities is no longer a valid parameter within the v1.1 API (it was in the v1 API). You may also need to provide a screen name, as I believe setting the .account property on the request is only for OAuth purposes.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top