[英]Display facebook recommendations plugin when user is logged in
I want to display the facebook recommendations plugin when user is login into facebook.当用户登录 facebook 时,我想显示 facebook 推荐插件。 I don't want to show the plugin when user is not logged into facebook because the result looks unpleasing.当用户未登录 facebook 时,我不想显示该插件,因为结果看起来令人不快。 Is this even possible?这甚至可能吗? How would I implement this to my site?我将如何在我的网站上实现这一点?
Thank you in adavance!提前谢谢你! Maca玛卡
facebook social plugin (Recommendations) https://developers.facebook.com/docs/reference/plugins/recommendations/facebook社交插件(推荐)
I already have the Javascript SDK like below implemented in the page.我已经在页面中实现了如下所示的 Javascript SDK。 I also have jQuery1.5.2 loaded in the page.我还在页面中加载了 jQuery1.5.2。
<div id="fb-root"></div> <script>
window.fbAsyncInit = function() {
FB.init({
appId : 'APP ID',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
channelUrl : 'http://urltomysite.com/channel.html' // custom channel
}); };
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());</script>
Here is the tag for recomendations plugin这是推荐插件的标签
<fb:recommendations site="urltomysite.com" width="300" height="300" header="true" font="" border_color=""></fb:recommendations>
You can use FB.getLoginSTatus to check if a user is logged into FB.您可以使用FB.getLoginSTatus来检查用户是否登录到 FB。 With the response from this function, you can decide whether to show your recommendation or not.通过此 function 的响应,您可以决定是否显示您的推荐。
FB.getLoginStatus(function(response) {
if (response.session) {
// logged in and connected user, someone you know
} else {
// no user session available, someone you dont know
}
});
Also Check: Check if user is logged in New Facebook API还要检查: 检查用户是否已登录 New Facebook API
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.