簡體   English   中英

如何從Twitter API的結果中獲取特定詳細信息?

[英]How to fetch specific details from the result of twitter api?

使用名為GET friends / list, https: //api.twitter.com/1.1/friends/list.json的twitter api,我可以獲取我關注的每個用戶的詳細信息。 我需要的是一些特定的數據,例如“地理”和“坐標”。 確實存在一個名為“ skip_status = true”的參數以跳過狀態。 但是請讓我知道是否可以單獨獲取“地理和坐標”或“狀態”。

"users": [
{
  "id": 3233xxxxxx,
  "id_str": "3233428303",
  "name": "Mars",
  "screen_name": "Mars9411",
  "location": "",
  "description": "",
  "url": null,
  "entities": {
    "description": {
      "urls": []
    }
  },
  "protected": false,
  "followers_count": 1,
  "friends_count": 0,
  "listed_count": 0,
  "created_at": "Tue Jun 02 09:58:03 +0000 2015",
  "favourites_count": 0,
  "utc_offset": null,
  "time_zone": null,
  "geo_enabled": true,
  "verified": false,
  "statuses_count": 9,
  "lang": "en",
  "status": {
    "created_at": "Tue Oct 27 12:31:11 +0000 2015",
    "id": 6589842841878xxxx,
    "id_str": "65898428418781xxxx",
    "text": "Hey, Download the  app in your phone and you can have an Emergency Contact for FREE. It's Great.\nhttps://t.co/kEZg",
    "source": "<a href="http://www.apple.com" rel="nofollow">iOS</a>",
    "truncated": false,
    "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,
    "geo": {
      "type": "Point",
      "coordinates": [
        28.612486,
        77.377425
      ]
    },
    "coordinates": {
      "type": "Point",
      "coordinates": [
        77.377425,
        28.612486
      ]
    },
    "place": {
      "id": "2e6064382c71b343",
      "url": "https://api.twitter.com/1.1/geo/id/2e606438.json",
      "place_type": "city",
      "name": "Noida",
      "full_name": "Noida, Uttar Pradesh",
      "country_code": "IN",
      "country": "India",
      "contained_within": [],
      "bounding_box": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              77.302126,
              28.4439811
            ],
            [
              77.6953257,
              28.4439811
            ],
            [
              77.6953257,
              28.6471308
            ],
            [
              77.302126,
              28.6471308
            ]
          ]
        ]
      },
      "attributes": {}
    },
    "contributors": null,
    "retweet_count": 0,
    "favorite_count": 0,
    "entities": {
      "hashtags": [],
      "symbols": [],
      "user_mentions": [],
      "urls": [
        {
          "url": "https://t.co/kEZ",
          "expanded_url": "http://www.sav.net/apps",
          "display_url": "sav.net/apps",
          "indices": [
            101,
            124
          ]
        }
      ]
    },
    "favorited": false,
    "retweeted": false,
    "possibly_sensitive": false,
    "lang": "en"
  },
  "contributors_enabled": false,
  "is_translator": false,
  "is_translation_enabled": false,
  "profile_background_color": "C0DEED",
  "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
  "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
  "profile_background_tile": false,
  "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png",
  "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_0_normal.png",
  "profile_link_color": "0084B4",
  "profile_sidebar_border_color": "C0DEED",
  "profile_sidebar_fill_color": "DDEEF6",
  "profile_text_color": "333333",
  "profile_use_background_image": true,
  "has_extended_profile": false,
  "default_profile": true,
  "default_profile_image": true,
  "following": true,
  "follow_request_sent": false,
  "notifications": false,
  "muting": false,
  "blocking": false,
  "blocked_by": false
},
{
  "id": 741xxxxxx,
  "id_str": "741xxxxxx",
  "name": "Food",
  "screen_name": "food",
  "location": "Fort, IN",
  "description": "Locally xxxxx",
  "url": "http://t.co",
  "entities": {
    "url": {
      "urls": [
        {
          "url": "http://t.co",
          "expanded_url": "http://Food.com",
          "display_url": "food.com",
          "indices": [
            0,
            22
          ]
        }
      ]
    },
    "description": {
      "urls": []
    }
  },
  "protected": false,
  "followers_count": 1976,
  "friends_count": 375,
  "listed_count": 44,
  "created_at": "Tue Aug 07 02:10:46 +0000 2012",
  "favourites_count": 247,
  "utc_offset": -14400,
  "time_zone": "Eastern Time (US & Canada)",
  "geo_enabled": true,
  "verified": false,
  "statuses_count": 1349,
  "lang": "en",
  "status": {
    "created_at": "Sun Oct 25 01:52:10 +0000 2015",
    "id": 658098694xxxxxxxxx,
    "id_str": "658098694xxxxxxxxx",
    "text": "@BenjamenKelly tonight!",
    "source": "<a href="http://twitter.com/download/iphone" rel="nofollow">Twitter for iPhone</a>",
    "truncated": false,
    "in_reply_to_status_id": 657368006075486200,
    "in_reply_to_status_id_str": "657368006075486208",
    "in_reply_to_user_id": 509529431,
    "in_reply_to_user_id_str": "509529431",
    "in_reply_to_screen_name": "Kelly",
    "geo": null,
    "coordinates": null,
    "place": {
      "id": "3877d6c867447819",
      "url": "https://api.twitter.com/1.1/geo/id/3877d6c867447819.json",
      "place_type": "city",
      "name": "Fort",
      "full_name": "Fort, IN",
      "country_code": "US",
      "country": "United States",
      "contained_within": [],
      "bounding_box": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              -85.336872,
              40.95926
            ],
            [
              -85.003231,
              40.95926
            ],
            [
              -85.003231,
              41.214574
            ],
            [
              -85.336872,
              41.214574
            ]
          ]
        ]
      },
      "attributes": {}
    },
    "contributors": null,
    "retweet_count": 0,
    "favorite_count": 1,
    "entities": {
      "hashtags": [],
      "symbols": [],
      "user_mentions": [
        {
          "screen_name": "Benj",
          "name": "boy",
          "id": 509529431,
          "id_str": "509529431",
          "indices": [
            0,
            14
          ]
        }
      ],
      "urls": []
    },
    "favorited": false,
    "retweeted": false,
    "lang": "en"
  },
  "contributors_enabled": false,
  "is_translator": false,
  "is_translation_enabled": false,
  "profile_background_color": "C0DEED",
  "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
  "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
  "profile_background_tile": false,
  "profile_image_url": "http://pbs.twimg.com/profile_images/2479745010/yz4eu6wrca8c5e2hw6x9_normal.jpeg",
  "profile_image_url_https": "https://pbs.twimg.com/profile_images/2479745010/yz4eu6wrca8c5e2hw6x9_normal.jpeg",
  "profile_banner_url": "https://pbs.twimg.com/profile_banners/741935389/1444260221",
  "profile_link_color": "0084B4",
  "profile_sidebar_border_color": "C0DEED",
  "profile_sidebar_fill_color": "DDEEF6",
  "profile_text_color": "333333",
  "profile_use_background_image": true,
  "has_extended_profile": false,
  "default_profile": true,
  "default_profile_image": false,
  "following": true,
  "follow_request_sent": false,
  "notifications": false,
  "muting": false,
  "blocking": false,
  "blocked_by": false
}

這就是我得到的(假設我的追蹤者中只有2個用戶)。 我需要的如下:

     "geo": {
      "type": "Point",
      "coordinates": [
        28.612486,
        77.377425
      ]
    },
    "coordinates": {
      "type": "Point",
      "coordinates": [
        77.377425,
        28.612486
      ]
    },
 "geo": null,
    "coordinates": null,

您需要自己從結果中過濾掉那些細節。 API將返回完整的person對象,而不是特定字段。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM