2016-01-15 4 views
1

Когда я тестирую свое приложение с помощью GET друзей/списка API twitter, «следующий» ключ JSON всегда оказывается ложным/нулевым, даже если пользователь следит за мной. Почему этот сценарий продолжается?«follow» key всегда возвращает false в get friends/list API Twitter

Пример JSON

{ 
 
    "users": [{ 
 
    "id": 103550181, 
 
    "id_str": "103550181", 
 
    "name": "Crowdfire", 
 
    "screen_name": "Crowdfire", 
 
    "location": "Everywhere", 
 
    "description": "Publish, engage and grow better on Twitter and Instagram. Available on mobile and web. 13 million users.", 
 
    "url": "https:\/\/t.co\/MEjmtjz2An", 
 
    "entities": { 
 
     "url": { 
 
     "urls": [{ 
 
      "url": "https:\/\/t.co\/MEjmtjz2An", 
 
      "expanded_url": "http:\/\/www.crowdfireapp.com", 
 
      "display_url": "crowdfireapp.com", 
 
      "indices": [0, 23] 
 
     }] 
 
     }, 
 
     "description": { 
 
     "urls": [] 
 
     } 
 
    }, 
 
    "protected": false, 
 
    "followers_count": 4270829, 
 
    "friends_count": 202935, 
 
    "listed_count": 6121, 
 
    "created_at": "Sun Jan 10 11:47:21 +0000 2010", 
 
    "favourites_count": 6434, 
 
    "utc_offset": 19800, 
 
    "time_zone": "Mumbai", 
 
    "geo_enabled": true, 
 
    "verified": false, 
 
    "statuses_count": 33003, 
 
    "lang": "en", 
 
    "status": { 
 
     "created_at": "Thu Jan 14 17:20:38 +0000 2016", 
 
     "id": 687685769708711936, 
 
     "id_str": "687685769708711936", 
 
     "text": "@NaveenS16 would you like to name some of them? #cfchat", 
 
     "source": "\u003ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003eTwitter Web Client\u003c\/a\u003e", 
 
     "truncated": false, 
 
     "in_reply_to_status_id": 687685529454809088, 
 
     "in_reply_to_status_id_str": "687685529454809088", 
 
     "in_reply_to_user_id": 749455278, 
 
     "in_reply_to_user_id_str": "749455278", 
 
     "in_reply_to_screen_name": "NaveenS16", 
 
     "geo": null, 
 
     "coordinates": null, 
 
     "place": null, 
 
     "contributors": null, 
 
     "retweet_count": 25, 
 
     "favorite_count": 58, 
 
     "entities": { 
 
     "hashtags": [{ 
 
      "text": "cfchat", 
 
      "indices": [48, 55] 
 
     }], 
 
     "symbols": [], 
 
     "user_mentions": [{ 
 
      "screen_name": "NaveenS16", 
 
      "name": "Naveen-Themesfinity", 
 
      "id": 749455278, 
 
      "id_str": "749455278", 
 
      "indices": [0, 10] 
 
     }], 
 
     "urls": [] 
 
     }, 
 
     "favorited": false, 
 
     "retweeted": false, 
 
     "lang": "en" 
 
    }, 
 
    "contributors_enabled": false, 
 
    "is_translator": false, 
 
    "is_translation_enabled": false, 
 
    "profile_background_color": "0099B9", 
 
    "profile_background_image_url": "http:\/\/abs.twimg.com\/images\/themes\/theme4\/bg.gif", 
 
    "profile_background_image_url_https": "https:\/\/abs.twimg.com\/images\/themes\/theme4\/bg.gif", 
 
    "profile_background_tile": false, 
 
    "profile_image_url": "http:\/\/pbs.twimg.com\/profile_images\/615941584706650112\/nYaFiaed_normal.png", 
 
    "profile_image_url_https": "https:\/\/pbs.twimg.com\/profile_images\/615941584706650112\/nYaFiaed_normal.png", 
 
    "profile_banner_url": "https:\/\/pbs.twimg.com\/profile_banners\/103550181\/1450267030", 
 
    "profile_link_color": "0099B9", 
 
    "profile_sidebar_border_color": "5ED4DC", 
 
    "profile_sidebar_fill_color": "95E8EC", 
 
    "profile_text_color": "3C3940", 
 
    "profile_use_background_image": true, 
 
    "has_extended_profile": false, 
 
    "default_profile": false, 
 
    "default_profile_image": false, 
 
    "following": false, 
 
    "follow_request_sent": false, 
 
    "notifications": false, 
 
    "muting": false, 
 
    "blocking": false, 
 
    "blocked_by": false 
 
    }, { 
 
    "id": 4176844046, 
 
    "id_str": "4176844046", 
 
    "name": "Anamika Nayan", 
 
    "screen_name": "anamika_nayan", 
 
    "location": "", 
 
    "description": "", 
 
    "url": null, 
 
    "entities": { 
 
     "description": { 
 
     "urls": [] 
 
     } 
 
    }, 
 
    "protected": false, 
 
    "followers_count": 1, 
 
    "friends_count": 41, 
 
    "listed_count": 0, 
 
    "created_at": "Mon Nov 09 07:27:26 +0000 2015", 
 
    "favourites_count": 0, 
 
    "utc_offset": null, 
 
    "time_zone": null, 
 
    "geo_enabled": false, 
 
    "verified": false, 
 
    "statuses_count": 0, 
 
    "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_4_normal.png", 
 
    "profile_image_url_https": "https:\/\/abs.twimg.com\/sticky\/default_profile_images\/default_profile_4_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": false, 
 
    "follow_request_sent": false, 
 
    "notifications": false, 
 
    "muting": false, 
 
    "blocking": false, 
 
    "blocked_by": false 
 
    }, { 
 
    "id": 29921858, 
 
    "id_str": "29921858", 
 
    "name": "Sandip Saha", 
 
    "screen_name": "withsandip", 
 
    "location": "", 
 
    "description": "Technology geek | Co-founder @ Innofied Solution Pvt Ltd | Husband to a lovely wife.", 
 
    "url": "http:\/\/t.co\/y7Swu7hNK6", 
 
    "entities": { 
 
     "url": { 
 
     "urls": [{ 
 
      "url": "http:\/\/t.co\/y7Swu7hNK6", 
 
      "expanded_url": "http:\/\/www.sandipsaha.com", 
 
      "display_url": "sandipsaha.com", 
 
      "indices": [0, 22] 
 
     }] 
 
     }, 
 
     "description": { 
 
     "urls": [] 
 
     } 
 
    }, 
 
    "protected": false, 
 
    "followers_count": 161, 
 
    "friends_count": 288, 
 
    "listed_count": 3, 
 
    "created_at": "Thu Apr 09 04:36:46 +0000 2009", 
 
    "favourites_count": 2, 
 
    "utc_offset": null, 
 
    "time_zone": null, 
 
    "geo_enabled": false, 
 
    "verified": false, 
 
    "statuses_count": 75, 
 
    "lang": "en", 
 
    "status": { 
 
     "created_at": "Fri Jan 08 04:21:37 +0000 2016", 
 
     "id": 685315393624248320, 
 
     "id_str": "685315393624248320", 
 
     "text": "RT @innofied: 16 New Year Resolutions to Welcome 2016 in Innofied - https:\/\/t.co\/6dUq8h6WmZ via @innofied", 
 
     "source": "\u003ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c\/a\u003e", 
 
     "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": null, 
 
     "coordinates": null, 
 
     "place": null, 
 
     "contributors": null, 
 
     "retweeted_status": { 
 
     "created_at": "Thu Jan 07 12:08:24 +0000 2016", 
 
     "id": 685070477706919936, 
 
     "id_str": "685070477706919936", 
 
     "text": "16 New Year Resolutions to Welcome 2016 in Innofied - https:\/\/t.co\/6dUq8h6WmZ via @innofied", 
 
     "source": "\u003ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003eTwitter Web Client\u003c\/a\u003e", 
 
     "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": null, 
 
     "coordinates": null, 
 
     "place": null, 
 
     "contributors": null, 
 
     "retweet_count": 4, 
 
     "favorite_count": 1, 
 
     "entities": { 
 
      "hashtags": [], 
 
      "symbols": [], 
 
      "user_mentions": [{ 
 
      "screen_name": "innofied", 
 
      "name": "Innofied", 
 
      "id": 461027581, 
 
      "id_str": "461027581", 
 
      "indices": [82, 91] 
 
      }], 
 
      "urls": [{ 
 
      "url": "https:\/\/t.co\/6dUq8h6WmZ", 
 
      "expanded_url": "http:\/\/goo.gl\/lmRKJK", 
 
      "display_url": "goo.gl\/lmRKJK", 
 
      "indices": [54, 77] 
 
      }] 
 
     }, 
 
     "favorited": false, 
 
     "retweeted": false, 
 
     "possibly_sensitive": false, 
 
     "lang": "en" 
 
     }, 
 
     "retweet_count": 4, 
 
     "favorite_count": 0, 
 
     "entities": { 
 
     "hashtags": [], 
 
     "symbols": [], 
 
     "user_mentions": [{ 
 
      "screen_name": "innofied", 
 
      "name": "Innofied", 
 
      "id": 461027581, 
 
      "id_str": "461027581", 
 
      "indices": [3, 12] 
 
     }, { 
 
      "screen_name": "innofied", 
 
      "name": "Innofied", 
 
      "id": 461027581, 
 
      "id_str": "461027581", 
 
      "indices": [96, 105] 
 
     }], 
 
     "urls": [{ 
 
      "url": "https:\/\/t.co\/6dUq8h6WmZ", 
 
      "expanded_url": "http:\/\/goo.gl\/lmRKJK", 
 
      "display_url": "goo.gl\/lmRKJK", 
 
      "indices": [68, 91] 
 
     }] 
 
     }, 
 
     "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:\/\/pbs.twimg.com\/profile_images\/603224208\/san_face_normal.jpg", 
 
    "profile_image_url_https": "https:\/\/pbs.twimg.com\/profile_images\/603224208\/san_face_normal.jpg", 
 
    "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": false, 
 
    "follow_request_sent": false, 
 
    "notifications": false, 
 
    "muting": false, 
 
    "blocking": false, 
 
    "blocked_by": false 
 
    }, { 
 
    "id": 281135790, 
 
    "id_str": "281135790", 
 
    "name": "manoj bose", 
 
    "screen_name": "manoj_bose", 
 
    "location": "", 
 
    "description": "", 
 
    "url": null, 
 
    "entities": { 
 
     "description": { 
 
     "urls": [] 
 
     } 
 
    }, 
 
    "protected": false, 
 
    "followers_count": 3, 
 
    "friends_count": 10, 
 
    "listed_count": 0, 
 
    "created_at": "Tue Apr 12 18:17:41 +0000 2011", 
 
    "favourites_count": 0, 
 
    "utc_offset": null, 
 
    "time_zone": null, 
 
    "geo_enabled": false, 
 
    "verified": false, 
 
    "statuses_count": 2, 
 
    "lang": "en", 
 
    "status": { 
 
     "created_at": "Tue Nov 06 18:22:31 +0000 2012", 
 
     "id": 265881866744254464, 
 
     "id_str": "265881866744254464", 
 
     "text": "Hello", 
 
     "source": "\u003ca href=\"http:\/\/www.nimbuzz.com\" rel=\"nofollow\"\u003eNimbuzz Mobile\u003c\/a\u003e", 
 
     "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": null, 
 
     "coordinates": null, 
 
     "place": null, 
 
     "contributors": null, 
 
     "retweet_count": 0, 
 
     "favorite_count": 0, 
 
     "entities": { 
 
     "hashtags": [], 
 
     "symbols": [], 
 
     "user_mentions": [], 
 
     "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:\/\/abs.twimg.com\/sticky\/default_profile_images\/default_profile_5_normal.png", 
 
    "profile_image_url_https": "https:\/\/abs.twimg.com\/sticky\/default_profile_images\/default_profile_5_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": false, 
 
    "follow_request_sent": false, 
 
    "notifications": false, 
 
    "muting": false, 
 
    "blocking": false, 
 
    "blocked_by": false 
 
    }, { 
 
    "id": 3187734769, 
 
    "id_str": "3187734769", 
 
    "name": "Parul", 
 
    "screen_name": "ParulGarg819", 
 
    "location": "", 
 
    "description": "", 
 
    "url": null, 
 
    "entities": { 
 
     "description": { 
 
     "urls": [] 
 
     } 
 
    }, 
 
    "protected": false, 
 
    "followers_count": 6, 
 
    "friends_count": 55, 
 
    "listed_count": 0, 
 
    "created_at": "Thu May 07 13:03:00 +0000 2015", 
 
    "favourites_count": 0, 
 
    "utc_offset": null, 
 
    "time_zone": null, 
 
    "geo_enabled": false, 
 
    "verified": false, 
 
    "statuses_count": 0, 
 
    "lang": "en-gb", 
 
    "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\/596302789027868672\/wudduWN7_normal.jpg", 
 
    "profile_image_url_https": "https:\/\/pbs.twimg.com\/profile_images\/596302789027868672\/wudduWN7_normal.jpg", 
 
    "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": false, 
 
    "follow_request_sent": false, 
 
    "notifications": false, 
 
    "muting": false, 
 
    "blocking": false, 
 
    "blocked_by": false 
 
    }], 
 
    "next_cursor": 1523322916963527611, 
 
    "next_cursor_str": "1523322916963527611", 
 
    "previous_cursor": 0, 
 
    "previous_cursor_str": "0" 
 
}

ответ

0

Если вы запрашиваете его для другого пользователя, чем для пользователя, делающего запрос аутентификации, то он может иметь много ложных ценностей, основан его статус последующих на аутентифицированного пользователя.

https://api.twitter.com/1.1/friends/list.json?cursor=-1&screen_name=twitterapi&skip_status=true&include_user_entities=false

Таким образом, для общего счета, как twitterapi, скорее всего, вы будете иметь много ложных значений, в то время как для screen_name, который следует аналогичные счета вы будете иметь истинные ценности.

Попробуйте без указания имени screen_name, и вы всегда должны иметь истинные значения.

+0

Есть ли какое-либо решение для того же, если я хочу получить значения «true» для конкретного пользователя, предоставив свои имена экранов ... –

+0

Это действительно зависит от того, что вы пытаетесь сделать. Если вам нужен список полных пользователей из списка друзей/списка, но затем узнайте, кто их следует, вы можете сделать отдельный звонок, чтобы получить этот список идентификаторов и рассчитать логическое значение самостоятельно. https://dev.twitter.com/rest/reference/get/followers/ids альтернативно вы можете выполнить вызов как аутентифицированный пользователь. –