Tweet图片上的twitter api休息响应

时间:2016-06-18 15:01:42

标签: android twitter twitter-fabric

https://api.twitter.com/1.1/statuses/show.json?id=210462857140252672 { "coordinates": null, "favorited": false, "truncated": false, "created_at": "Wed Jun 06 20:07:10 +0000 2012", "id_str": "210462857140252672", "entities": { "urls": [ { "expanded_url": "https://dev.twitter.com/terms/display-guidelines", "url": "https://url", "indices": [ 76, 97 ], "display_url": "dev.twitter.com/terms/display-\u2026" } ], "hashtags": [ { "text": "Twitterbird", "indices": [ 19, 31 ] } ], "user_mentions": [ ] }, "in_reply_to_user_id_str": null, "contributors": [ 14927800 ], "text": "Along with our new #Twitterbird, we've also updated our Display Guidelines: https://url", "retweet_count": 66, "in_reply_to_status_id_str": null, "id": 210462857140252672, "geo": null, "retweeted": true, "possibly_sensitive": false, "in_reply_to_user_id": null, "place": null, "user": { "profile_sidebar_fill_color": "DDEEF6", "profile_sidebar_border_color": "C0DEED", "profile_background_tile": false, "name": "Twitter API", "profile_image_url": "http://a0.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_normal.png", "created_at": "Wed May 23 06:01:13 +0000 2007", "location": "San Francisco, CA", "follow_request_sent": false, "profile_link_color": "0084B4", "is_translator": false, "id_str": "6253282", "entities": { "url": { "urls": [ { "expanded_url": null, "url": "http://dev.twitter.com", "indices": [ 0, 22 ] } ] }, "description": { "urls": [ ] } }, "default_profile": true, "contributors_enabled": true, "favourites_count": 24, "url": "http://dev.twitter.com", "profile_image_url_https": "https://si0.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_normal.png", "utc_offset": -28800, "id": 6253282, "profile_use_background_image": true, "listed_count": 10774, "profile_text_color": "333333", "lang": "en", "followers_count": 1212963, "protected": false, "notifications": null, "profile_background_image_url_https": "http://si0.twimg.com/images/themes/theme1/bg.png", "profile_background_color": "C0DEED", "verified": true, "geo_enabled": true, "time_zone": "Pacific Time (US & Canada)", "description": "The Real Twitter API. I tweet about API changes, service issues and happily answer questions about Twitter and our API. Don't get an answer? It's on my website.", "default_profile_image": false, "profile_background_image_url": "http://a0.twimg.com/images/themes/theme1/bg.png", "statuses_count": 3333, "friends_count": 31, "following": true, "show_all_inline_media": false, "screen_name": "twitterapi" }, "in_reply_to_screen_name": null, "source": "web", "in_reply_to_status_id": null } 对获取推文信息的示例回复。

{{1}}

问题是,什么是包含推文图像的字段(如果存在)?因为没有像'tweet_image'那样的字段或类似的东西

1 个答案:

答案 0 :(得分:2)

此推文没有附加任何图像。具有图像的Tweet的主体将具有包含extended_entities个实体的media树。您可以在Twitter documentation中详细了解相关信息。这是我最近发布的附有图片的推文的一个例子。

{
  "created_at": "Mon Jul 11 21:50:25 +0000 2016",
  "id": 752621088723566592,
  "id_str": "752621088723566592",
  "text": "Darned Pidgey is after my beer. (link)",
  "truncated": false,
  "entities": {
    "hashtags": [

    ],
    "symbols": [

    ],
    "user_mentions": [

    ],
    "urls": [
      {
        "url": "(link)",
        "expanded_url": "http://pipr.co/29zNseX",
        "display_url": "pipr.co/29zNseX",
        "indices": [
          32,
          55
        ]
      }
    ],
    "media": [
      {
        "id": 752621086345465856,
        "id_str": "752621086345465856",
        "indices": [
          56,
          79
        ],
        "media_url": "http://pbs.twimg.com/media/CnHY4_YXEAAYm9J.jpg",
        "media_url_https": "https://pbs.twimg.com/media/CnHY4_YXEAAYm9J.jpg",
        "url": "(link)",
        "display_url": "pic.twitter.com/S1pIUQisNW",
        "expanded_url": "http://twitter.com/andypiper/status/752621088723566592/photo/1",
        "type": "photo",
        "sizes": {
          "medium": {
            "w": 582,
            "h": 582,
            "resize": "fit"
          },
          "thumb": {
            "w": 150,
            "h": 150,
            "resize": "crop"
          },
          "large": {
            "w": 582,
            "h": 582,
            "resize": "fit"
          },
          "small": {
            "w": 582,
            "h": 582,
            "resize": "fit"
          }
        }
      }
    ]
  },
  "extended_entities": {
    "media": [
      {
        "id": 752621086345465856,
        "id_str": "752621086345465856",
        "indices": [
          56,
          79
        ],
        "media_url": "http://pbs.twimg.com/media/CnHY4_YXEAAYm9J.jpg",
        "media_url_https": "https://pbs.twimg.com/media/CnHY4_YXEAAYm9J.jpg",
        "url": "(link)",
        "display_url": "pic.twitter.com/S1pIUQisNW",
        "expanded_url": "http://twitter.com/andypiper/status/752621088723566592/photo/1",
        "type": "photo",
        "sizes": {
          "medium": {
            "w": 582,
            "h": 582,
            "resize": "fit"
          },
          "thumb": {
            "w": 150,
            "h": 150,
            "resize": "crop"
          },
          "large": {
            "w": 582,
            "h": 582,
            "resize": "fit"
          },
          "small": {
            "w": 582,
            "h": 582,
            "resize": "fit"
          }
        }
      }
    ]
  },
  "source": "<a href=\"http://ifttt.com\" rel=\"nofollow\">IFTTT</a>",
  "in_reply_to_status_id": null,
  "in_reply_to_status_id_str": null,
  "in_reply_to_user_id": null,
  "in_reply_to_user_id_str": null,
  "in_reply_to_screen_name": null,
  "user": {
    "id": 786491,
    "id_str": "786491",
    "name": "Pipes",
    "screen_name": "andypiper",
    "location": "Kingston upon Thames, London",
    "description": "I'm on the @TwitterDev team, supporting and listening to developers working on the Twitter platform. Code, community, and respect. #HeForShe",
    "url": "(link)",
    "entities": {
      "url": {
        "urls": [
          {
            "url": "(link)",
            "expanded_url": "http://about.me/andypiper",
            "display_url": "about.me/andypiper",
            "indices": [
              0,
              23
            ]
          }
        ]
      },
      "description": {
        "urls": [

        ]
      }
    },
    "protected": false,
    "followers_count": 13542,
    "friends_count": 3898,
    "listed_count": 781,
    "created_at": "Wed Feb 21 15:14:48 +0000 2007",
    "favourites_count": 65599,
    "utc_offset": 3600,
    "time_zone": "London",
    "geo_enabled": true,
    "verified": false,
    "statuses_count": 89932,
    "lang": "en",
    "contributors_enabled": false,
    "is_translator": false,
    "is_translation_enabled": false,
    "profile_background_color": "ACDEEE",
    "profile_background_image_url": "http://abs.twimg.com/images/themes/theme18/bg.gif",
    "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme18/bg.gif",
    "profile_background_tile": false,
    "profile_image_url": "http://pbs.twimg.com/profile_images/753281917944893440/63g61GqD_normal.jpg",
    "profile_image_url_https": "https://pbs.twimg.com/profile_images/753281917944893440/63g61GqD_normal.jpg",
    "profile_banner_url": "https://pbs.twimg.com/profile_banners/786491/1468424285",
    "profile_link_color": "6EA8E6",
    "profile_sidebar_border_color": "FFFFFF",
    "profile_sidebar_fill_color": "F6F6F6",
    "profile_text_color": "333333",
    "profile_use_background_image": true,
    "has_extended_profile": true,
    "default_profile": false,
    "default_profile_image": false,
    "following": false,
    "follow_request_sent": false,
    "notifications": false
  },
  "geo": null,
  "coordinates": null,
  "place": null,
  "contributors": null,
  "is_quote_status": false,
  "retweet_count": 1,
  "favorite_count": 11,
  "favorited": false,
  "retweeted": false,
  "possibly_sensitive": false,
  "possibly_sensitive_appealable": false,
  "lang": "en"
}