我可以使用 facebook SDK 和 python 获取喜欢 public 页面的粉丝列表(姓名 - 电子邮件)吗?
Can I get a list (name - email) of fans who likes a public page using the facebook SDK and python?
我正在尝试获取喜欢 public 页面的粉丝列表。
如果不可能,请列出喜欢该 public 页面中的评论的人。
这个link让我觉得事实上这是可能的:
https://www.facebook.com/search/102381354573/likers?ref=about
这是我使用 Python 和 Facebook SDK
尝试的结果
"""
A simple example script to get all posts on a user's timeline.
Originally created by Mitchell Stewart.
<https://gist.github.com/mylsb/10294040>
"""
import facebook
import requests
def some_action(post, row):
""" Here you might want to do something with each post. E.g. grab the
post's message (post['message']) or the post's picture (post['picture']).
"""
# You'll need an access token here to do anything. You can get a temporary one
# here: https://developers.facebook.com/tools/explorer/
access_token = 'EAATASQOiIDABAC367RRjcCNY8SHWkNaeaZBEByStOCx6arJcMZAsLHvAwBzHmVpzNR9kjaM5G4GsoiEzEkr0YXYoA0rSHdtXXSGMn8RQgrA3ZB2nmBGYQ0rUGFKL6dtAZCEjkfuMFy5hBHLKqDiDs95CiUBcbkKYZCAFA559qiAZDZD'
# Look at Bill Gates's profile for this example by using his Facebook id.
user = 'biligates'
graph = facebook.GraphAPI(access_token)
profile = graph.get_object(user)
likes = graph.get_connections('102381354573', 'likes')
posts = graph.get_connections(profile['id'], 'posts')
while True:
try:
[print_friends(friends=friend) for friend in likes['data']]
likes = requests.get(likes['paging']['next']).json()
except KeyError:
# When there are no more pages (['paging']['next']), break from the
# loop and end the script.
print ('--------------------')
print ('No more data comming')
print ('--------------------')
break
这个脚本的结果是:
{u'name': u'Washington Redskins', u'id': u'102381354573'}
32237381874 - Kings Dominion
328084609453 - Pierre Thomas
164582060550453 - Papa John's Pizza DMV
112733772094151 - CSN Mid-Atlantic
758770517542315 - Matt Jones
291800575745 - Andre Roberts
546765258765348 - Stephen Paea
487760671369099 - DeSean Jackson
110815543982 - DeAngelo Hall
386180624733248 - Robert Griffin III
1397352627212077 - Dashon Goldson
155219064665 - Pierre Garçon
1557530721156959 - Akeem Davis
159691050732 - Kirk Cousins
1433685776950292 - Redskins Salute
89972093868 - Omni Hotels
525973260837198 - Redskins Team Store
678000172307735 - Family of 3
120167766006 - FanDuel
161882187173357 - Bradenton Redskins Fan Club
668604919890894 - Redskins Facts
188327264572436 - Bob's Discount Furniture
164933623547236 - PrimeSport
352567624896549 - True Health Diagnostics
218158744892220 - Women of Washington Redskins
503110669738004 - Bon Secours Washington Redskins Training Center
267502171241 - NFL Ticket Exchange
174705179277205 - Washington Redskins Cheerleaders
370174424170 - NFL Network
68680511262 - NFL
--------------------
No more data comming
--------------------
没有,没有API获取粉丝列表。您只能获取在您的主页上发表评论或点赞的用户列表,但无法获取他们的电子邮件。无论如何都会很奇怪,你想用电子邮件做什么?如果没有用户的明确批准,您甚至不允许存储电子邮件,您发送给他们的任何电子邮件都将是垃圾邮件。
您只能通过向用户授予 email
权限才能获得该用户的电子邮件。
我正在尝试获取喜欢 public 页面的粉丝列表。
如果不可能,请列出喜欢该 public 页面中的评论的人。
这个link让我觉得事实上这是可能的:
https://www.facebook.com/search/102381354573/likers?ref=about
这是我使用 Python 和 Facebook SDK
尝试的结果"""
A simple example script to get all posts on a user's timeline.
Originally created by Mitchell Stewart.
<https://gist.github.com/mylsb/10294040>
"""
import facebook
import requests
def some_action(post, row):
""" Here you might want to do something with each post. E.g. grab the
post's message (post['message']) or the post's picture (post['picture']).
"""
# You'll need an access token here to do anything. You can get a temporary one
# here: https://developers.facebook.com/tools/explorer/
access_token = 'EAATASQOiIDABAC367RRjcCNY8SHWkNaeaZBEByStOCx6arJcMZAsLHvAwBzHmVpzNR9kjaM5G4GsoiEzEkr0YXYoA0rSHdtXXSGMn8RQgrA3ZB2nmBGYQ0rUGFKL6dtAZCEjkfuMFy5hBHLKqDiDs95CiUBcbkKYZCAFA559qiAZDZD'
# Look at Bill Gates's profile for this example by using his Facebook id.
user = 'biligates'
graph = facebook.GraphAPI(access_token)
profile = graph.get_object(user)
likes = graph.get_connections('102381354573', 'likes')
posts = graph.get_connections(profile['id'], 'posts')
while True:
try:
[print_friends(friends=friend) for friend in likes['data']]
likes = requests.get(likes['paging']['next']).json()
except KeyError:
# When there are no more pages (['paging']['next']), break from the
# loop and end the script.
print ('--------------------')
print ('No more data comming')
print ('--------------------')
break
这个脚本的结果是:
{u'name': u'Washington Redskins', u'id': u'102381354573'}
32237381874 - Kings Dominion
328084609453 - Pierre Thomas
164582060550453 - Papa John's Pizza DMV
112733772094151 - CSN Mid-Atlantic
758770517542315 - Matt Jones
291800575745 - Andre Roberts
546765258765348 - Stephen Paea
487760671369099 - DeSean Jackson
110815543982 - DeAngelo Hall
386180624733248 - Robert Griffin III
1397352627212077 - Dashon Goldson
155219064665 - Pierre Garçon
1557530721156959 - Akeem Davis
159691050732 - Kirk Cousins
1433685776950292 - Redskins Salute
89972093868 - Omni Hotels
525973260837198 - Redskins Team Store
678000172307735 - Family of 3
120167766006 - FanDuel
161882187173357 - Bradenton Redskins Fan Club
668604919890894 - Redskins Facts
188327264572436 - Bob's Discount Furniture
164933623547236 - PrimeSport
352567624896549 - True Health Diagnostics
218158744892220 - Women of Washington Redskins
503110669738004 - Bon Secours Washington Redskins Training Center
267502171241 - NFL Ticket Exchange
174705179277205 - Washington Redskins Cheerleaders
370174424170 - NFL Network
68680511262 - NFL
--------------------
No more data comming
--------------------
没有,没有API获取粉丝列表。您只能获取在您的主页上发表评论或点赞的用户列表,但无法获取他们的电子邮件。无论如何都会很奇怪,你想用电子邮件做什么?如果没有用户的明确批准,您甚至不允许存储电子邮件,您发送给他们的任何电子邮件都将是垃圾邮件。
您只能通过向用户授予 email
权限才能获得该用户的电子邮件。