风火家人开发记要

技术总结精华贴

Tag: FaceBook

其他, 原创

facebook邀请好友加入应用使用fb:fbml标签无效解决方案

使用 fb:fbml 标签无效,需要在页面中加入这样一段代码 <div id=”fb-root”></div> <script type=”text/javascript”> window.fbAsyncInit = function() { FB.init({ appId : “YOUR_APP_ID”, channelUrl : “//YOUR_DOMAIN.COM/channel.html”, status : true, cookie : true, xfbml : true }); // Additional initialization code here }; // Load the SDK Asynchronously (function(d){ var js, id = ‘facebook-jssdk’, ref = d.getElementsByTagName(‘script’)[0]; if (d.getElementById(id)) {return;} js = d.createElement(‘script’); js.id = id; js.async = true; js.src = “//connect.facebook.net/en_US/all.js”; ref.parentNode.insertBefore(js, ref); }(document)); </ script> 这里面提到的url不要加http或者https,系统会根据当前协议自动补齐的。 上面代码使用的是 javascript SDK ,摘自 http://developers.facebook.com/docs/reference/javascript/ 这样就可以在html中使用fb:fbml标签了 下面例子是邀请好友加入应用 <fb:serverFbml style=”width: 755px;”> <script type=”text/fbml”> <fb:fbml> <fb:request-form action=”<URL for post invite action, see fb:request-form docs for details>” method=”POST” invite=”true” type=”XFBML” content=”This is a test invitation from XFBML test app <fb:req-choice url=”see fb:req-choice docs for details.” label=”Ignore the Facebook test app!” /> “> </fb:request-form> <fb:multi-friend-selector showborder=”false” actiontext=”Invite your friends to use Facebook.” /> </fb:fbml> </script> </fb:serverFbml> 通过上面的的js调用就可以正常显示上面fb代码了,希望对你有所帮助。 (774)

查看全文