简体   繁体   English

像使用内置图一样的api的Facebook商业页面无法与javascript sdk一起使用

[英]Like facebook business page using built-in like open-graph api not working with javascript sdk

How do I like a Facebook business page once the user has logged in and authorized my app to Publish on his/her behalf? 用户登录并授权我的应用程序代表他/她发布后,我如何喜欢Facebook企业页面? Here's my code so far: 到目前为止,这是我的代码:

window.fbAsyncInit = function() {
    FB.init({ appId: 'MY_APP_ID',                    
        status: true, 
        cookie: true,
        xfbml: true,
        oauth: true});

        document.getElementById('fb-auth').addEventListener('click', function() {
          FB.login(function(response){
            if(response.authResponse){ // user has authorized app
                FB.api('/me/likes/BUS_PAGE_ID', function(response){
                    if(response.data.length>0) {
                       // user has liked the page
                    } else {
                       // like the page for the user                                  
                    }
                });
            }
          }, {scope:'publish_actions, user_likes'});
        }, false);
};

The code is working to the point that it authorizes the app and I can see if the business page is liked by the user with FB.api(...) if(response.data.length>0). 该代码正在工作,以至于它授权了该应用,并且我可以使用FB.api(...)if(response.data.length> 0)来查看用户是否喜欢该业务页面。 What do I put in the place of // like the page for the user so that my app can like a specific business page and add it to the user's likes? 我应该在///这样的用户页面中放置什么,以便我的应用可以喜欢特定的业务页面并将其添加到用户的喜欢中? Thank you. 谢谢。

Actions can only be used for objects outside of Facebook. 动作只能用于Facebook之外的对象。

You cannot use the built-in like action and you definitely cannot force a user to like a Facebook page. 您不能使用内置的like动作,并且绝对不能强迫用户喜欢Facebook页面。

Use the Like box or redirect the user to your Facebook page. 使用“ 喜欢”框或将用户重定向到您的Facebook页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM