Twitter4j搜索只获得少数字段

时间:2015-01-09 14:51:59

标签: java twitter twitter4j

Twitter4j搜索返回包含许多字段的结果。

例如:

StatusJSONImpl{createdAt=Fri Jan 09 19:56:31 IST 2015, id=553558441482924033, text='Avast Free Antivirus 2015 [Download]: Avast Free Antivirus 2015 [Download] by AVAST Software s.r.o. Platform:… http://t.co/0zLPutC1PU', source='<a href="http://dlvr.it" rel="nofollow">dlvr.it</a>', isTruncated=false, inReplyToStatusId=-1, inReplyToUserId=-1, isFavorited=false, isRetweeted=false, favoriteCount=0, inReplyToScreenName='null', geoLocation=null, place=null, retweetCount=0, isPossiblySensitive=false, isoLanguageCode='en', lang='en', contributorsIDs=[], retweetedStatus=null, userMentionEntities=[], urlEntities=[URLEntityJSONImpl{url='http://t.co/0zLPutC1PU', expandedURL='http://amzn.to/1q69X9Z', displayURL='amzn.to/1q69X9Z'}], hashtagEntities=[], mediaEntities=[], symbolEntities=[], currentUserRetweetId=-1, user=UserJSONImpl{id=2792966010, name='Jessica', screenName='JessicaN372', location='US', description='Jessica', isContributorsEnabled=false, profileImageUrl='http://pbs.twimg.com/profile_images/508946722307846144/E5Bi70E8_normal.jpeg', profileImageUrlHttps='https://pbs.twimg.com/profile_images/508946722307846144/E5Bi70E8_normal.jpeg', url='null', isProtected=false, followersCount=128, status=null, profileBackgroundColor='C0DEED', profileTextColor='333333', profileLinkColor='0084B4', profileSidebarFillColor='DDEEF6', profileSidebarBorderColor='C0DEED', profileUseBackgroundImage=true, showAllInlineMedia=false, friendsCount=0, createdAt=Sat Sep 06 08:13:33 IST 2014, favouritesCount=0, utcOffset=-1, timeZone='null', profileBackgroundImageUrl='http://abs.twimg.com/images/themes/theme1/bg.png', profileBackgroundImageUrlHttps='https://abs.twimg.com/images/themes/theme1/bg.png', profileBackgroundTiled=false, lang='en', statusesCount=148653, isGeoEnabled=false, isVerified=false, translator=false, listedCount=2, isFollowRequestSent=false}}

我只需要文字和链接。

如何仅请求某些字段

1 个答案:

答案 0 :(得分:0)

由于Twitter Search API无法提供此功能,因此无法请求某些字段。

相反,您需要自己从Status中提取您感兴趣的内容。

在您的情况下,您可以使用status.getText()status.getUrlEntities()来获得所需内容。