找到你要的答案

Q:Follow Facebook User With Facebook API (JavaScript)

Q:按照脸谱网的用户与脸谱网的API(JavaScript)

I want to create a button which onClick will follow specified user on Facebook with their API in JavaScript but, I came across nothing so I have no clue - is it even possible?

我想创建一个按钮的onclick将按照与API JavaScript脸谱网指定的用户但是我碰到什么我不知道-这可能吗?

answer1: 回答1:

This facebook documentation page includes instructions concerning how to create a follow button using the facebook API:

Include the JavaScript SDK on your page once, ideally right after the opening tag.

<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_GB/sdk.js#xfbml=1&version=v2.3&appId=999677273376981";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

Place the code for your plugin wherever you want the plugin to appear on your page.

<div class="fb-follow" data-href="https://www.facebook.com/zuck" data-colorscheme="light" data-layout="standard" data-show-faces="true"></div>

To change the user pointed to change the data-href attribute of the follow button:

<div class="fb-follow" data-href="https://www.facebook.com/{the person you want to follow}" data-colorscheme="light" data-layout="standard" data-show-faces="true"></div>

本脸谱网文档页包括有关如何使用脸谱网API创建后续按钮的说明:

包括页面上的JavaScript SDK后,开放标签后理想的权利。

<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_GB/sdk.js#xfbml=1&version=v2.3&appId=999677273376981";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

无论你想让插件出现在你的页面上,都要为你的插件放置代码。

<;div class=“FB遵循“数据链接为“https://www.facebook.com/zuck”数据的配色方案=“光”数据布局=“标准”数据显示面=“true”>;<;/ div & gt;

更改用户指出改变跟随按钮href属性的数据:

<div class="fb-follow" data-href="https://www.facebook.com/{the person you want to follow}" data-colorscheme="light" data-layout="standard" data-show-faces="true"></div>
javascript  facebook  api