如何正确检索Twitter4J中的“扩展媒体”网址?

时间:2015-12-15 20:06:42

标签: java api twitter twitter4j

我和我的小组正在使用Twitter4J API,我们遇到了媒体问题。 如果我们直接发送推文,请使用:

status = twitter.showStatus(Long.parseLong(tweetId2pics));

这两张图片的网址同时显示为

getMedia.getMediaURL() 

getExtendedMedia.getMediaURL().

但是当我们使用查询来获取相同的推文时,请使用以下几行:

Query query = new Query(tweetId2pics);
    try {
        QueryResult results = twitter.search(query);
    }

扩展媒体字段似乎是空的。

这里请求返回的两个JSON(这些jSONs是相同的):

StatusJSONImpl{createdAt=Tue Dec 15 17:44:15 CET 2015, id=676804977189363712, text='Nouvel essai avec deux images #hashtagtoutnul https://t.co/o4d3Jefcy2', source='<a href="http://twitter.com" rel="nofollow">Twitter Web Client</a>', isTruncated=false, inReplyToStatusId=-1, inReplyToUserId=-1, isFavorited=false, isRetweeted=false, favoriteCount=0, inReplyToScreenName='null', geoLocation=null, place=PlaceJSONImpl{name='Nancy', streetAddress='null', countryCode='FR', id='66fabed9d649aa12', country='France', placeType='city', url='https://api.twitter.com/1.1/geo/id/66fabed9d649aa12.json', fullName='Nancy, Lorraine', boundingBoxType='Polygon', boundingBoxCoordinates=[[Ltwitter4j.GeoLocation;@256c668], geometryType='null', geometryCoordinates=null, containedWithIn=[]}, retweetCount=0, isPossiblySensitive=false, lang='fr', contributorsIDs=[], retweetedStatus=null, userMentionEntities=[], urlEntities=[], hashtagEntities=[HashtagEntityJSONImpl{text='hashtagtoutnul'}], mediaEntities=[MediaEntityJSONImpl{id=676804976056926208, url=https://t.co/o4d3Jefcy2, mediaURL=http://pbs.twimg.com/media/CWR-ijQXAAAuipc.png, mediaURLHttps=https://pbs.twimg.com/media/CWR-ijQXAAAuipc.png, expandedURL=http://twitter.com/SteakdeNiche/status/676804977189363712/photo/1, displayURL='pic.twitter.com/o4d3Jefcy2', sizes={0=Size{width=150, height=150, resize=101}, 1=Size{width=340, height=191, resize=100}, 2=Size{width=600, height=337, resize=100}, 3=Size{width=1024, height=576, resize=100}}, type=photo}], symbolEntities=[], currentUserRetweetId=-1, user=UserJSONImpl{id=366530792, name='SteakdeNiche ', screenName='SteakdeNiche', location='France', description='French engineer student, video games lover, electro-music listener. ~ Don't forget, what you want will be. ~', isContributorsEnabled=false, profileImageUrl='http://pbs.twimg.com/profile_images/461515308834889729/9sC6qD9x_normal.jpeg', profileImageUrlHttps='https://pbs.twimg.com/profile_images/461515308834889729/9sC6qD9x_normal.jpeg', isDefaultProfileImage=false, url='null', isProtected=false, followersCount=39, status=null, profileBackgroundColor='EDECE9', profileTextColor='BD2A2A', profileLinkColor='94D487', profileSidebarFillColor='000000', profileSidebarBorderColor='FFFFFF', profileUseBackgroundImage=true, isDefaultProfile=false, showAllInlineMedia=false, friendsCount=151, createdAt=Fri Sep 02 12:28:05 CEST 2011, favouritesCount=48, utcOffset=3600, timeZone='Paris', profileBackgroundImageUrl='http://pbs.twimg.com/profile_background_images/442649966905810945/x5poZ0qE.jpeg', profileBackgroundImageUrlHttps='https://pbs.twimg.com/profile_background_images/442649966905810945/x5poZ0qE.jpeg', profileBackgroundTiled=true, lang='fr', statusesCount=288, isGeoEnabled=true, isVerified=false, translator=false, listedCount=0, isFollowRequestSent=false, withheldInCountries=null}, withHeldInCountries=null, quotedStatusId=-1, quotedStatus=null}

StatusJSONImpl{createdAt=Tue Dec 15 17:44:15 CET 2015, id=676804977189363712, text='Nouvel essai avec deux images #hashtagtoutnul https://t.co/o4d3Jefcy2', source='<a href="http://twitter.com" rel="nofollow">Twitter Web Client</a>', isTruncated=false, inReplyToStatusId=-1, inReplyToUserId=-1, isFavorited=false, isRetweeted=false, favoriteCount=0, inReplyToScreenName='null', geoLocation=null, place=PlaceJSONImpl{name='Nancy', streetAddress='null', countryCode='FR', id='66fabed9d649aa12', country='France', placeType='city', url='https://api.twitter.com/1.1/geo/id/66fabed9d649aa12.json', fullName='Nancy, Lorraine', boundingBoxType='Polygon', boundingBoxCoordinates=[[Ltwitter4j.GeoLocation;@48688905], geometryType='null', geometryCoordinates=null, containedWithIn=[]}, retweetCount=0, isPossiblySensitive=false, lang='fr', contributorsIDs=[], retweetedStatus=null, userMentionEntities=[], urlEntities=[], hashtagEntities=[HashtagEntityJSONImpl{text='hashtagtoutnul'}], mediaEntities=[MediaEntityJSONImpl{id=676804976056926208, url=https://t.co/o4d3Jefcy2, mediaURL=http://pbs.twimg.com/media/CWR-ijQXAAAuipc.png, mediaURLHttps=https://pbs.twimg.com/media/CWR-ijQXAAAuipc.png, expandedURL=http://twitter.com/SteakdeNiche/status/676804977189363712/photo/1, displayURL='pic.twitter.com/o4d3Jefcy2', sizes={0=Size{width=150, height=150, resize=101}, 1=Size{width=340, height=191, resize=100}, 2=Size{width=600, height=337, resize=100}, 3=Size{width=1024, height=576, resize=100}}, type=photo}], symbolEntities=[], currentUserRetweetId=-1, user=UserJSONImpl{id=366530792, name='SteakdeNiche ', screenName='SteakdeNiche', location='France', description='French engineer student, video games lover, electro-music listener. ~ Don't forget, what you want will be. ~', isContributorsEnabled=false, profileImageUrl='http://pbs.twimg.com/profile_images/461515308834889729/9sC6qD9x_normal.jpeg', profileImageUrlHttps='https://pbs.twimg.com/profile_images/461515308834889729/9sC6qD9x_normal.jpeg', isDefaultProfileImage=false, url='null', isProtected=false, followersCount=39, status=null, profileBackgroundColor='EDECE9', profileTextColor='BD2A2A', profileLinkColor='94D487', profileSidebarFillColor='000000', profileSidebarBorderColor='FFFFFF', profileUseBackgroundImage=true, isDefaultProfile=false, showAllInlineMedia=false, friendsCount=151, createdAt=Fri Sep 02 12:28:05 CEST 2011, favouritesCount=48, utcOffset=3600, timeZone='Paris', profileBackgroundImageUrl='http://pbs.twimg.com/profile_background_images/442649966905810945/x5poZ0qE.jpeg', profileBackgroundImageUrlHttps='https://pbs.twimg.com/profile_background_images/442649966905810945/x5poZ0qE.jpeg', profileBackgroundTiled=true, lang='fr', statusesCount=288, isGeoEnabled=true, isVerified=false, translator=false, listedCount=0, isFollowRequestSent=false, withheldInCountries=null}, withHeldInCountries=null, quotedStatusId=-1, quotedStatus=null}

有人可以向我们解释为什么第一个吸气剂都起作用,为什么只有getMedia才能用于第二个吸气剂?

先谢谢!

0 个答案:

没有答案