如何从 TwitterKit 获取媒体?

How to get media from TwitterKit?

我已使用以下代码获取 public 帐户的提要,但是,我无法获取图片、视频、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 数组,但它不包含任何媒体。

帮帮我。

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

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
         }

}];