2011-05-16 115 views
-4

我想在我的iphone应用程序中从twitter获取Twitter提要。如何获取twitter应用程序到iPhone应用程序?

我该怎么办?

+0

那你试试?你看过什么样的例子? – Eiko 2011-05-16 09:49:50

+0

尝试做一些,并询问你有问题。不要期望整个解决方案 – 2011-05-16 09:51:16

+0

http://stackoverflow.com/questions/5455057/how-to-display-twitter-feeds-in-iphone-sdk – Jhaliya 2011-05-16 09:59:18

回答

0

URLPath是格式的字符串: https://api.twitter.com/1.1/statuses/user_timeline.json?count=40&user_id=your_user_id&screen_name=screen_name_you_want

TWRequest *twRequest = nil; 
    NSURLRequest *postRequest = nil; 

    twRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:URLPath] 
            parameters:nil requestMethod:TWRequestMethodGET]; 

    ACAccountStore *accountStore = [[ACAccountStore alloc] init]; 
    ACAccountType *twitterAccountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]; 
    ACAccount *twitterAccount = [[accountStore accountsWithAccountType:twitterAccountType] objectAtIndex:0]; 

    if (twitterAccount) { 
     twRequest.account = [accountStore accountWithIdentifier:((ACAccount *)twitterAccount).identifier]; 
     postRequest = [twRequest signedURLRequest]; 

     connectionRequest = [[NSURLConnection alloc] initWithRequest:postRequest delegate:self]; 
     if(connectionRequest) 
      responseData = [[NSMutableData alloc] init]; 
    } 
相关问题