如何通过Facebook获得publish_actions权限

时间:2013-10-13 09:52:03

标签: facebook

我跟随导师与Facebook联系,使用以下代码成功连接到Facebook。

代码如下 -

FB.Event.subscribe('auth.authResponseChange', function (response) {
                if (response.status === 'connected') {
                    // the user is logged in and has authenticated your
                    // app, and response.authResponse supplies
                    // the user's ID, a valid access token, a signed
                    // request, and the time the access token 
                    // and signed request each expire
                    var uid = response.authResponse.userID;
                    var accessToken = response.authResponse.accessToken;

                    // TODO: Handle the access token

                    // Do a post to the server to finish the logon
                    // This is a form post since we don't want to use AJAX
                    var form = document.createElement("form");
                    form.setAttribute("method", 'post');
                    form.setAttribute("action", 'loadMainPage.ashx');

                    var field = document.createElement("input");
                    field.setAttribute("type", "hidden");
                    field.setAttribute("name", 'accessToken');
                    field.setAttribute("value", accessToken);
                    form.appendChild(field);

                    document.body.appendChild(form);
                    form.submit();

                } else if (response.status === 'not_authorized') {
                    // the user is logged in to Facebook, 
                    // but has not authenticated your app
                } else {
                    // the user isn't logged in to Facebook.
                }
            });

        };

如何申请publish_actions权限?

1 个答案:

答案 0 :(得分:0)

您使用的是什么平台?请参阅Facebook's official docs

摘录:

  

申请权限

     

每种类型的登录流都有自己的请求这些权限的方法:

     
      
  • 使用JavaScript SDK进行Web登录时,会使用带有FB.login函数调用的范围选项。
  •   
  • 其他类型的Web登录应将scope参数添加到Login   他们重定向到的对话框网址。
  •   
  • Android登录使用setReadPermissions和setPublishPermissions   在LoginButton类上。
  •   
  • iOS登录使用readPermissions和publishPermissions属性   在FBLoginView类中。
  •