LoginSignup
0
0

More than 5 years have passed since last update.

自分以外のユーザの作ったリストを取得する

Last updated at Posted at 2016-06-03

フォローイング/フォロワーの作ったリストのリストが欲しくなって、そういうものを作るツールを作った時のメモ。

はじめTweepyでやろうと思ったんだけど、自分以外の持っているリストを取得する、つまりlists/listlists/ownershipslists/subscriptionsなどに対応する機能が見つけられなかった。

結局自力でやることになった。なんで無いんだろう……

from requests_oauthlib import OAuth1Session
import json

session = OAuth1Session(consumer_key, consumer_secret, access_token, access_token_secret)

api_url = 'https://api.twitter.com/1.1/lists/ownerships.json'
params = {'user_id': userid}
req = session.get(api_url, params=params)

if req.status_code == 200:
    jsn = json.loads(req.text)
    for item in jsn['lists']:
        print(item['name'])
else:
    print('Error: %d' % req.status_code)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0