2011-05-16 213 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]; 
    } 
相關問題