邀请Facebook的朋友加入网站与蟒蛇社会认证 [英] Inviting Facebook Friends to join site with python social auth
问题描述
我试图首先从使用Facebook帐户登录的用户获取朋友列表。我没有运气跟随这个帖子:如何使用Python-Social-auth和Django检索Facebook的朋友的信息
每当我调用应该检索的视图,我会得到空的朋友Facebook的朋友。理想情况下,我想检索Facebook的朋友,并在邀请用户的朋友注册网络应用程序的一边有一个邀请按钮。
这是我在我的views.py中有的:
social_user = request.user.social_auth.filter(provider ='facebook',)。first()
pre>
如果social_user:
url = u'https://graph.facebook.com/ {0} / '\
u'friends?fields = id,name,location,picture'\
u'& access_token = {1}'。format(
social_user.uid,
social_user.extra_data ['access_token'],
)
request2 = urllib2.Request(url)
friends = json.loads(urllib2.urlopen(request2).read())。 get('data')
return render_to_response('friends / friends.html',{'user':request.user,'friends':friends})
解决方案自从Graph API 2.0+以来,您只能得到正在使用您的应用程序的朋友。您发布的链接显示了如何在v1.0中完成,该版本不再可用。
https://developers.facebook.com/docs/graph-api/reference/v2.2/user/friends
- 需要使用user_friends权限的用户访问令牌才能查看当前的朋友。
- 这将只返回任何已经使用(通过Facebook登录)发出请求的应用程序的朋友。
- 如果该人的朋友拒绝user_friends权限,该朋友不会显示在这个人的朋友列表中。
所以如果没有朋友使用你的应用程序未被授予
user_friends
列表将为空。
还为邀请的朋友 https://developers.facebook.com/docs/graph-api/reference/v2.2/user/invitable_friends
Invitable Friends API只适用于分类为Games的应用程序,它们也有Canvas存在。该API在v1.0中不可用。只要手机游戏也有Canvas存在,它可能会被调用。
剩下的唯一方式是href =https://developers.facebook.com/docs/sharing/reference/send-dialog =nofollow> https://developers.facebook.com/docs/sharing/reference/send-dialog
I'm trying to first get the list of friends from a user who is logged in using a facebook account. I have followed this post with no luck: How to retrieve Facebook friend's information with Python-Social-auth and Django
I get and empty friends set everytime I call the view that is supposed to retrieve the facebook friends. Ideally, I would like to retrieve the facebook friends and have an invite button on the side that invites the user's friends to sign up for web app.
This is what I have in my views.py:
social_user = request.user.social_auth.filter(provider='facebook',).first() if social_user: url = u'https://graph.facebook.com/{0}/' \ u'friends?fields=id,name,location,picture' \ u'&access_token={1}'.format( social_user.uid, social_user.extra_data['access_token'], ) request2 = urllib2.Request(url) friends = json.loads(urllib2.urlopen(request2).read()).get('data') return render_to_response('friends/friends.html', {'user': request.user, 'friends':friends})
解决方案Ever since Graph API 2.0+ You can only get the friends who are using your application. The link you posted shows how it was done in v1.0 which is no longer available.
https://developers.facebook.com/docs/graph-api/reference/v2.2/user/friends
- A user access token with user_friends permission is required to view the current person's friends.
- This will only return any friends who have used (via Facebook Login) the app making the request.
- If a friend of the person declines the user_friends permission, that friend will not show up in the friend list for this person.
So if no friends have used your application and not granted
user_friends
the list will be empty.Also for invitable friends https://developers.facebook.com/docs/graph-api/reference/v2.2/user/invitable_friends
The Invitable Friends API is only available to apps classified as Games, which also have a Canvas presence. This API is not available in v1.0. It may be called by mobile games as long as they also have a Canvas presence.
The only way left to do this is https://developers.facebook.com/docs/sharing/reference/send-dialog
这篇关于邀请Facebook的朋友加入网站与蟒蛇社会认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!