facebook rauth python friendslist不可用

时间:2013-06-25 05:20:59

标签: python facebook

我有来自

的代码片段

https://github.com/litl/rauth/blob/master/examples/facebook/facebook.py

def authorized():
    # check to make sure the user authorized the request
    if not 'code' in request.args:
        flash('You did not authorize the request')
        return redirect(url_for('index'))

    # make a request for the access token credentials using code
    redirect_uri = url_for('authorized', _external=True)
    data = dict(code=request.args['code'], redirect_uri=redirect_uri)

    session = facebook.get_auth_session(data=data)

    # the "me" response
    me = session.get('me').json()

    User.get_or_create(me['username'], me['id'])

#print(me['first_name'])
#flash('Logged in as ' + me['name'])
    flash('Logged in as ' + me['name'])
    for key, value in me.iteritems():
    print key, value
    return redirect(url_for('index'))

主要问题是哈希“我”不包含任何关键字对应的朋友列表。但是在图表浏览器中

https://developers.facebook.com/tools/explorer/?method=GET&path=xxxxxxxfields%3Dfriendlists

我可以点击“+”符号弹出列表中的好友列表,点击提交即可获取好友列表。因此,如何使用rauth API获取好友列表?

由于

1 个答案:

答案 0 :(得分:0)

呃,我明白了:

friends = session.get('<id>/friends').json();