Search code examples
iostwitter

What goes wrong to access twitter timeline account?


I tried the fallowing code to get access twitter timeline. It doesn't received any data from the server.What went wrong here?

 ACAccount *twitterAccount=[arrayOfAccounts lastObject];

            NSURL *requestURL=[NSURL URLWithString:@"http://api.twitter.com/1/statuses/user_timeline.json"];

            NSMutableDictionary *parameters=[NSMutableDictionary new];
            //[parameters setObject:@"100" forKey:@"count"];
            //[parameters setObject:@"1" forKey:@"include_entities"];

            SLRequest *post=[SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:requestURL parameters:parameters];

            post.account=twitterAccount;

            [post performRequestWithHandler:^(NSData *response, NSHTTPURLResponse *urlResponse, NSError *error) {

                self.array=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];
                if(self.array.count !=0)
                    NSLog(@"%@",self.array);
                else
                    NSLog(@"No Data Recived");

Thanks in advance.


Solution

  • Twitter has advice to use Version 1.1 not advice v1. In version 1.1 api https,So try to use this url https://api.twitter.com/1.1/statuses/user_timeline.json instated of this url http://api.twitter.com/1/statuses/user_timeline.json. This work's fine.