2011-08-17 40 views
1

我是iPhone應用程序開發的新手,並試圖創建一個基於Twitter的iPhone應用程序。 我使用MGTwitterEngine來搜索和檢索我關注的人的時間表。 我使用的方法是:MGTwitterEngine不返回重新推文,只有「原始」推文

[twitterEngine getFollowedTimelineSinceID:0 startingAtPage:0 count:100]; 

事情是偉大的工作,但有幾件事情我奮鬥着:

  1. 我只獲得了微博原帖由我跟着名單,根本沒有重新推特。我真的很想在同一個調用中獲得所有的推文(原始和重新推文),但是如果我需要執行兩個請求(一個用於推文,一個用於重新推文),這對我來說也會很好。
  2. 我收到了不到100條推文,儘管我知道一個事實,那就是我關注的人張貼了更多。任何想法如何解決它?

有人提到MGTwitterEngine缺乏重新推特功能。我不想重新推特,只是爲了獲得完整的時間表(包括我關注的人的推文)。

非常感謝!

+0

你已經採取了看看MG源代碼,看看API調用它正在爲getFollowed ...我會做到這一點,再看看twitter API文檔,以確保轉發甚至應該回來的電話。 – shawnwall

+0

謝謝shawnwall,我會看看getFollowed執行的實際api調用。關於Twitter API - 它看起來像Twitter API確實支持獲取轉發。 – user898836

回答

0

看這個https://dev.twitter.com/docs/api/1/get/statuses/home_timeline

具體看一部分說:

Include_RTS : When set to either true, t or 1,the timeline will contain native retweets (if they exist) in addition to the standard stream of tweets... 

現在在getFollowedTimelineSinceID方法,你需要創建一個新的對象爲PARAMS沿着這些路線

字典的東西

[params setObject:[NSString stringWithFormat:@"%@", @"true"] forKey:@"Include_RTS"];

+1

謝謝@bizsytes像魅力一樣工作。 根據您的建議,我對getFollowedTimelineSinceID進行了兩項修改: 1.將路徑字符串從@statuses/friends_timeline。%@更改爲@statuses/home_timeline。%@ 2。添加了Include_RTS對象 顯然,它解決了我的問題(轉推和檢索到的狀態數量)。 – user898836

+0

哦,是啊,我有點沒有說friend_timeline被棄用,因爲這不是原來的問題。 +1可以自己搞清楚:)另外,您可以添加其他任何參數,例如,您可以添加一個參數來知道您是否轉推了特定的推文。默認返回的轉推參數總是假,並且還有另一種解決方法來確定推文是否已被您轉發。 – bizsytes

0

每@bizsytes建議我已經做了兩個月difications到MGTwitterEngine的 getFollowedTimelineSinceID方法:。

  1. 改變了路徑串從@狀態/ friends_timeline%@到@狀態/ home_timeline%@

  2. 添加了Include_RTS對象

顯然它解決了我的問題(轉推&檢索到的狀態數量)。

現在的方法現在看起來如下:

- (NSString *)getAllFollowedTimelineSinceID:(unsigned long)sinceID withMaximumID:(unsigned long)maxID startingAtPage:(int)page count:(int)count 
{ 
    NSString *path = [NSString stringWithFormat:@"statuses/home_timeline.%@", API_FORMAT]; 

    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:0]; 
    if (sinceID > 0) { 
     [params setObject:[NSString stringWithFormat:@"%u", sinceID] forKey:@"since_id"]; 
    } 
    if (maxID > 0) { 
     [params setObject:[NSString stringWithFormat:@"%u", maxID] forKey:@"max_id"]; 
    } 
    if (page > 0) { 
     [params setObject:[NSString stringWithFormat:@"%d", page] forKey:@"page"]; 
    } 
    if (count > 0) { 
     [params setObject:[NSString stringWithFormat:@"%d", count] forKey:@"count"]; 
    } 

    [params setObject:[NSString stringWithFormat:@"%@", @"true"] forKey:@"Include_RTS"]; 


    return [self _sendRequestWithMethod:nil path:path queryParameters:params body:nil 
          requestType:MGTwitterFollowedTimelineRequest 
          responseType:MGTwitterStatuses]; 
}