71

我想获得喜欢某个页面或它的粉丝的用户列表。

FB API 文档指出,您只能使用社交图谱获取某个页面的粉丝数,而不能获取粉丝列表。

Retrieve Facebook Fan Names此处的讨论表明,可以使用 FQL 查询SELECT user_id FROM like WHERE object_id="YOUR PAGE ID"来获取喜欢该页面的人数,但对于同一页面,它会给出一个空响应“{}”。

所以我想知道是否有人知道这是否可以做到。

4

8 回答 8

70

有一种“方法”可以在没有令牌的情况下使用某些粉丝页面的个人资料 ID 来获取粉丝列表的某些部分。

  1. 使用公共图形数据获取粉丝页面的 ID:http ://graph.facebook.com/cocacola - 可口可乐有 40796308305。 更新 2016.04.30:Facebook 现在需要访问令牌才能通过图形获取 page_id,以便您可以解析粉丝页面 HTML 语法https://www.facebook.com/{PAGENAME}根据粉丝页面上的 og 标签,在没有任何授权的情况下从下面的示例中获取此 ID 。
  2. 使用一些修改的参数直接获取可口可乐的“like plugin” iframe 显示:http: //www.facebook.com/plugins/fan.php? connections=100&id=40796308305
  3. 现在检查页面来源,有很多粉丝链接到他们的个人资料,您可以在其中找到他们的个人资料 ID 或昵称,例如: http: //www.facebook.com/michal.semeniuk
  4. 如果您只对个人资料 ID 感兴趣,请再次使用图形 API - 它会直接为您提供个人资料 ID:http: //graph.facebook.com/michal.semeniuk更新 2016.04.30:Facebook 现在需要访问令牌才能获取此类信息。您可以解析配置文件 HTML 语法,就像在第一步中元标记是您最好的朋友一样: <meta property="al:android:url" content="fb://profile/{PROFILE_ID}" />

现在是最好的部分:尝试刷新(F5)第 2 点中的链接.. 有一套新的全套可口可乐的另一个粉丝。只选择独特的,您将能够获得一些不错的,几乎完整的粉丝列表。

-- 更新 2013.08.06 --

你为什么不使用我准备好的 PHP 脚本来获取一些粉丝?:)

更新 2016.04.30:更新示例脚本以在 Facebook 开始要求访问令牌以从图形 api 获取公共数据后使用新方法。

function fetch_fb_fans($fanpage_name, $no_of_retries = 10, $pause = 500000 /* 500ms */){
    $ret = array();
    // prepare real like user agent and accept headers
    $context = stream_context_create(array('http' => array('header' => 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/49.0.2623.108 Chrome/49.0.2623.108 Safari/537.36\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\nAccept-encoding: gzip, deflate, sdch\r\nAccept-language: en-US,en;q=0.8,pl;q=0.6\r\n')));
    // get page id from facebook html og tags for mobile apps
    $fanpage_html = file_get_contents('https://www.facebook.com/' . $fanpage_name, false, $context);
    if(!preg_match('{fb://page/(\d+)}', $fanpage_html, $id_matches)){
        // invalid fanpage name
        return $ret;
    }
    $url = 'http://www.facebook.com/plugins/fan.php?connections=100&id=' . $id_matches[1];
    for($a = 0; $a < $no_of_retries; $a++){
        $like_html = file_get_contents($url, false, $context);
        preg_match_all('{href="https?://www\.facebook\.com/([a-zA-Z0-9\._-]+)" class="link" data-jsid="anchor" target="_blank"}', $like_html, $matches);
        if(empty($matches[1])){
            // failed to fetch any fans - convert returning array, cause it might be not empty
            return array_keys($ret);
        }else{
            // merge profiles as array keys so they will stay unique
            $ret = array_merge($ret, array_flip($matches[1]));
        }
        // don't get banned as flooder
        usleep($pause);
    }
    return array_keys($ret);
}

print_r(fetch_fb_fans('TigerPolska', 2, 400000));
于 2012-06-05T23:22:25.520 回答
41

您可以使用新的 Facebook 搜索来吸引粉丝:https ://www.facebook.com/search/321770180859/likers?ref=about

于 2013-05-22T13:06:49.783 回答
10

用这个。

https://www.facebook.com/browse/?type=page_fans&page_id=<your page id>

它将返回多达 500 个最近的赞。

http://www.facebook.com/browse/?type=page_fans&page_id=<your page id>&start=400

每个页面会给你100个粉丝。将起始值更改为 (0, 100, 200, 300, 400) 以获得前 500。如果起始值 >= 401,则页面将为空白 :(

于 2013-01-24T09:48:10.950 回答
7

根据Facebook 文档,不可能获得一个页面的所有粉丝:

虽然您无法获得 Facebook 主页的所有粉丝的列表,但您可以查明某个特定的人是否喜欢某个主页。

于 2014-06-10T11:09:12.807 回答
3

对于 s3m3n 的回答,Facebook 粉丝插件(例如LAMODA)现在有限制,您在持续请求中获得的新粉丝越来越少。您可以尝试我修改后的 PHP 脚本来可视化结果:https ://gist.github.com/liruqi/7f425bd570fa8a7c73be#file-facebook_fans_by_plugin-php

另一种方法是 Facebook 图搜索。在搜索结果页面上:喜欢名为“Lamoda”的页面的人,打开 Chrome 控制台并运行 JavaScript:

var run = 0;
var mails = {}
total = 3000; //滚动次数,可以自己根据情况定义

function getEmails (cont) {
    var friendbutton=cont.getElementsByClassName("_ohe");
    for(var i=0; i<friendbutton.length; i++) {
        var link = friendbutton[i].getAttribute("href");

        if(link && link.substr(0,25)=="https://www.facebook.com/") {
            var parser = document.createElement('a');
            parser.href = link;
            if (parser.pathname) {
                path = parser.pathname.substr(1);
                if (path == "profile.php") {
                    search = parser.search.substr(1);
                    var args = search.split('&');
                    email = args[0].split('=')[1] + "@facebook.com\n";
                } else {
                    email = parser.pathname.substr(1) + "@facebook.com\n";
                }
                if (mails[email] > 0) {
                    continue;
                }
                mails[email] = 1;
                console.log(email);
            }
        }
    }
}

function moreScroll() {
    var text="";
    containerID = "BrowseResultsContainer"
    if (run > 0) {
        containerID = "fbBrowseScrollingPagerContainer" + (run-1);
    }
    var cont = document.getElementById(containerID);
    if (cont) {
        run++;
        var id = run - 2;
        if (id >= 0) {
            setTimeout(function() {
                containerID = "fbBrowseScrollingPagerContainer" + (id);
                var delcont = document.getElementById(containerID);
                if (delcont) {
                getEmails(delcont);
                delcont.parentNode.removeChild(delcont);
                }
                window.scrollTo(0, document.body.scrollHeight - 10);
            }, 1000);
        }
    } else {
        console.log("# " + containerID);
    }
    if (run < total) {
        window.scrollTo(0, document.body.scrollHeight + 10);
    }
    setTimeout(moreScroll, 2000);
}//1000为间隔时间,也可以根据情况定义

moreScroll();

它将加载新的粉丝并打印用户 ID/电子邮件,删除旧的 DOM 节点以避免页面崩溃。你可以在这里找到这个脚本

于 2015-06-17T09:21:26.487 回答
1

此页面https://developers.facebook.com/docs/reference/fql/like/写道,您无法获取粉丝列表。

“Post、Video、Note、Link、Photo 和 Album Graph API 对象包含一个名为 likes 的等效连接。”

注意:类似 fql 的查询已弃用

于 2011-10-27T12:31:30.453 回答
0

从技术上讲,这个 FQL 查询应该可以工作,但由于某种原因,Facebook 由于缺少索引而不允许它。不确定这是因为政策还是他们只是忘记了。

SELECT uid FROM page_fans WHERE page_id="YOUR_PAGE_ID"
于 2013-12-05T21:31:49.617 回答
0

我创建了一个小工具luster,用于下载您 Facebook 页面的“喜欢者”和“关注者”列表。

为您的平台下载并解压缩存档后,您可以从终端运行它

luster fans my-page-name

my-page-name您的 Facebook 页面的字符串标识符在哪里。

系统将要求您提供 Facebook 帐户的电子邮件和密码。请注意,此帐户需要具有可用的页面角色之一。即使是分析师也足够了。

一段时间后,您应该会收到类似于以下内容的输出

TIME,KIND,ID,NAME,LINK
1581665652,Like,111111111,John Doe,https://www.facebook.com/111111111
1581663355,Like,222222222,Kal Peterson,https://www.facebook.com/222222222
1581661970,Follow,333333333,Nikol Kus,https://www.facebook.com/333333333

此工具基于Settings -> People and Other Pages您的 Facebook 页面部分中的阅读表。

请注意,Facebook 方面最多有7k 个结果。我在拥有超过 20k 粉丝的两页上对其进行了测试,但没有得到超过 7k 的结果。

有关详细信息,请参阅https://github.com/zladovan/luster

于 2020-02-17T14:15:19.840 回答