Skip to content

Instantly share code, notes, and snippets.

@liluo
Last active December 15, 2015 23:59
Show Gist options
  • Save liluo/5344217 to your computer and use it in GitHub Desktop.
Save liluo/5344217 to your computer and use it in GitHub Desktop.
me = client.user.me print client.user.following(me['id'])
SCOPE = 'douban_basic_common,shuo_basic_r,shuo_basic_w,community_advanced_doumail_r'
client = DoubanClient(API_KEY, API_SECRET, CALLBACK, SCOPE)
print 'Go to the following link in your browser:'
print client.authorize_url
code = raw_input('Enter the verification code:')
access_token = client.auth_with_code(code)
  
  
# print client.user.get(client.user.me['loc_id']) 这句是有问题的
# client.user.me['loc_id'] 这个会获取当前用户的城市 id
# client.user.get(user_id) 这个接口是根据用户 id 获取用户信息的
# 如果你需要获取当前用户关注信息,应该这样:
me = client.user.me
print client.user.following(me['id'])
# 将获取到的 token 存储一下
print client.client.token # 存到 db 或者哪儿吧
## 以后直接用 auto_with_token 就可以了,见:
<https://github.com/douban/douban-client/blob/master/examples/auth_with_token.py>
# 需要注意有过期时间,我不太记得是多久了。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment