我可以使用facebook SDK和python获得喜欢公共页面的粉丝列表(姓名 - 电子邮件)吗?

时间:2016-09-08 18:08:07

标签: python json facebook facebook-graph-api sdk

我试图获得一个喜欢公共页面的粉丝列表。

如果无法获得喜欢在该公开页面中发表评论的人员列表。

这个链接让我觉得事实上它是可能的:

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
--------------------

1 个答案:

答案 0 :(得分:2)

不,没有API可以获得粉丝列表。您只能获得在您的网页上评论或喜欢某些内容的用户列表,但无法获取他们的电子邮件。无论如何,这将是奇怪的,你想用电子邮件做什么?未经用户明确批准,您甚至不允许存储电子邮件,并且您发送给他们的任何电子邮件都是垃圾邮件。

只有通过授权email权限的用户才能收到用户的电子邮件。