facebook - 我可以在 Facebook 主页上使用 facepile 吗?

标签 facebook facebook-page facepile

所以我有一个 Facebook 页面设置。我有一个外部网站,我想在上面使用 facepile。这个想法是当有人访问我的外部网站时,他们可以看到他们的哪些 Facebook 好友“喜欢”了 Facebook 页面。

我去了这里 https://developers.facebook.com/docs/plugins/facepile/ 上面写着

The Facepile plugin displays the Facebook profile photos of people who have connected with your Facebook page or app.

看来我可以用我的 Facebook 页面来做。

我找到了下面的代码

    <script>
  window.fbAsyncInit = function() {
    // init the FB JS SDK
    FB.init({
      appId      : '12345667809845',      // App ID from the app dashboard
      status     : true,                  // Check Facebook Login status
      xfbml      : true                   // Look for social plugins on the page
    });

    // Additional initialization code such as adding Event Listeners goes here
  };

  // Load the SDK asynchronously
  (function(){
     // If we've already installed the SDK, we're done
     if (document.getElementById('facebook-jssdk')) {return;}

     // Get the first script element, which we'll use to find the parent node
     var firstScriptElement = document.getElementsByTagName('script')[0];

     // Create a new script element and set its id
     var facebookJS = document.createElement('script'); 
     facebookJS.id = 'facebook-jssdk';

     // Set the new script's source to the source of the Facebook JS SDK
     facebookJS.src = '//connect.facebook.net/en_US/all.js';

     // Insert the Facebook JS SDK into the DOM
     firstScriptElement.parentNode.insertBefore(facebookJS, firstScriptElement);
   }());
</script>

然后再往下我有

<div class="fb-facepile" data-app-id='12345667809845' data-href="http://facebook.com/myfacebookpage" data-action="like" data-max-rows="1" data-colorscheme="light" data-size="medium" data-show-count="true"></div>

(重要的网址和号码已更改以保护无辜者)

如您所见,上面的代码总是在谈论 Facebook 应用程序而不是页面。如果有人能告诉我我做错了什么,我会很高兴!

更新:

所以澄清一下:

我想要做的是让 Facepile 在外部网站上显示有多少人喜欢我的 Facebook 页面。在我看来,我插入外部页面的代码中的某些内容需要告诉 Facepile 它需要从哪个页面获得点赞。从下面的评论来看,您似乎是在 data-href 中这样做的。

  1. 如果是这样,那么我应该在 app_id 中输入什么?

  2. 我是否需要将外部页面注册为 facebook 应用程序才能获取应用程序 ID?

最佳答案

所以答案是肯定的。您可以将 FacePile 与 FaceBook 页面一起使用。但是您需要先做一些其他事情。

您需要将外部页面注册为 FaceBook 应用程序。您可以在这里执行此操作

https://developers.facebook.com/apps

并创建一个新的应用程序。你需要指定你想用这个应用程序做什么,我发现最简单的说我想用 Facebook 登录(请注意,这个功能不需要存在于你的网站上,你只需要为 FaceBook 指定)。您在“站点 URL”的“登录到 Facebook”选项下添加您的外部站点 URL,瞧,您在外部网站 url 上有一个 facebook 应用程序。然后您还有一个应用程序 ID。

所以当你去

https://developers.facebook.com/docs/plugins/facepile/

要获取代码片段,您可以使用刚刚创建的 Facebook 应用程序(单击“获取代码”按钮后会出现一个下拉框,或者您可以在对话框中输入数字),“URL”是 url您想要点赞的 Facebook 页面。如果您单击“获取代码”按钮,您将获得一些类似以下的代码片段:

<div id="fb-root"></div>
<script>
(function(d, s, id) {   
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); 
    js.id = id;   
    js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=<YOUR_APP_ID_HERE>";  
    fjs.parentNode.insertBefore(js, fjs); 
}(document, 'script','facebook-jssdk'));
</script>

<div class="fb-facepile" data-href="http://facebook.com/<YOUR_PAGE_URL_HERE" data-max-rows="1" data-colorscheme="light" data-size="medium" data-show-count="true"></div>

将它们放在您的外部页面上(在替换值之后),facepile 应该可以工作!

希望这对其他人有帮助!

关于facebook - 我可以在 Facebook 主页上使用 facepile 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20291298/

相关文章:

Facebook API 搜索主题标签

iOS 10 的 Facebook 登录问题

Facebook 点赞按钮未与粉丝页面中的点赞链接?

php - 将数字粉丝页面ID转换为String粉丝页面id\粉丝页面名称

php - Facebook 标记视频

ruby-on-rails - 如何捕获 Koala::Facebook::APIError OAuthException 或用户密码重置

objective-c - 如何在 iOS Facebook 应用程序上加载 Facebook 页面链接

facebook - 如果用户未登录或没有 friend 连接到站点,则 Conceal facepile

css - 是否需要以及如何在 css 中定义它?