如何从twitter api的结果中获取具体细节?

时间:2015-10-30 04:45:25

标签: ios twitter

使用Twitter api命名为GET friends / list,https://api.twitter.com/1.1/friends/list.json我可以获得我关注的每个用户的详细信息。我需要的是一些特定的数据,' geo'和'坐标'再具体一点。确实存在一个名为' skip_status = true'跳过状态。但请告诉我,无论是“地理位置”还是“协调”。或者' status'可以独自获取。

"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,

1 个答案:

答案 0 :(得分:1)

您需要自己从结果中过滤掉这些细节。 API将返回完整的person对象,而不是特定的字段。