0

我已经使用以下代码获取公共帐户的提要,但是,我无法获取图像、视频、gif 等媒体。

TWTRAPIClient *APIClient = TWTRAPIClient.clientWithCurrentUser;
TWTRUserTimelineDataSource *newArray = [[TWTRUserTimelineDataSource alloc] initWithScreenName:@"TomCruise" APIClient:APIClient];

[newArray loadPreviousTweetsBeforePosition:@"0" completion:^(NSArray<TWTRTweet *> * _Nullable tweets, TWTRTimelineCursor * _Nullable cursor, NSError * _Nullable error) {
    for (int count=0; count<tweets.count; count++) {
        NSLog(@"tweet json is == \n%@",[tweets[count] tweetID]);
        NSLog(@"tweet text is == \n%@",[tweets[count] text]);
        [self.twitterarray addObject:[tweets[count] text]];
    }

    [self reloadCollectionView];
}];

在这里,我得到了数组TWTRTweet数组,但它不包含任何媒体。

帮我。

4

1 回答 1

0

您可以使用以下代码中的私有成员和类。

TWTRAPIClient *APIClient = TWTRAPIClient.clientWithCurrentUser;
    //TWTRUserTimelineDataSource *newArray =  [[TWTRUserTimelineDataSource alloc] initWithScreenName:@"TomCruise" APIClient:APIClient];
    TWTRUserTimelineDataSource *newArray= [[TWTRUserTimelineDataSource alloc] initWithScreenName:@"TomCruise" userID:nil APIClient:APIClient maxTweetsPerRequest:10 includeReplies:true includeRetweets:true];
    [newArray loadPreviousTweetsBeforePosition:@"0" completion:^(NSArray<TWTRTweet *> * _Nullable tweets, TWTRTimelineCursor * _Nullable cursor, NSError * _Nullable error) {
        for (int count=0; count<tweets.count; count++) {
            NSLog(@"tweet text is == %@ \n",[tweets[count] text]);
            NSLog(@"media %@",[[tweets[count] valueForKey:@"media"] valueForKey:@"mediaUrl"]);//_mediaUrl
         }

}];
于 2018-11-13T11:59:43.663 回答