Facebook之Social Plugins

什么是Social Plugin
引用
Social plugins
    Social plugins enable you to provide engaging social experiences to your users with just a line of HTML. Because the plugins are served by Facebook, the content is personalized to the viewer whether or not they have signed into your site.

简单地说:你想在你网站的某个网页上显示一个按钮、一小块html代码等来链接Facebook应用,那么只要引入facebook的API和一段fbml就可以达到目的。
<html>
	<body>
		<div id="fb-root"></div>
	</body>
</html>
<script>
  // 116344281725102 是一个facebook应用的app id.
  window.fbAsyncInit = function() {
    FB.init({appId: '116344281725102', status: true, cookie: true,
             xfbml: true});
  };
  (function() {
    var e = document.createElement('script'); 
	e.async = true;
    //e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    e.src = 'http://connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
  }());
</script>
<fb:login-button></fb:login-button>


浏览器中运行看看结果

猜你喜欢

转载自koda.iteye.com/blog/661124