フォロワー関連¶
本節では followers 系 REST API について記す。他人から自分に向かう関係の機能に followers の名前が含まれる。インターフェイスは friends 系の対応する機能と一致している。
GET followers/ids¶
GET followers/ids は GET friends/ids のフォロワー版だ。解説は フォロー関連 を参照。
#!/usr/bin/env python
# Demonstration GET followers/ids
# See https://dev.twitter.com/rest/reference/get/followers/ids
from secret import twitter_instance
tw = twitter_instance()
next_cursor = -1
while next_cursor:
    response = tw.followers.ids(
        stringify_ids=True,
        cursor=next_cursor)
    print(','.join(response['ids']))
    next_cursor = response['next_cursor']
GET followers/list¶
特定のユーザーをフォローしている全ユーザーの情報を得るのには GET followers/list を利用できる。解説は フォロー関連 を参照。
#!/usr/bin/env python
# Demonstration GET followers/list
# See https://dev.twitter.com/rest/reference/followers/list
from secret import twitter_instance
tw = twitter_instance()
next_cursor = -1
while next_cursor:
    response = tw.followers.list(
        screen_name='showa_yojyo',
        cursor=next_cursor,
        count=200,
        skip_status=True,
        include_user_entities=False,)
    for follower in response['users']:
        print('''
{screen_name} / {name}
{description}
{url}
'''.format_map(follower))
    next_cursor = response['next_cursor']