首页 文章

通过具有权限的API将Facebook应用程序添加到页面

提问于
浏览
0

如何通过具有Publish_stream权限的API将应用程序添加到页面(我已创建)?

这是我尝试使用应用程序轻松完成的事情序列 . 使用页面访问令牌代码向页面添加应用程序是将应用程序添加到页面应用程序部分,但无法添加“publish_stream,manage_pages”权限 .

登录Facebook

private const string Scope = "publish_stream,manage_pages";
   FacebookClient _fb = new FacebookClient();
   var fbLoginUrl = _fb.GetLoginUrl(
                new
                {
                    client_id = AppId,
                    client_secret = Appsecret,
                    redirect_uri = RedirectUri,
                    response_type = "code",
                    scope = Scope,
                    state = state
                });

获得短期访问令牌

if (Request.QueryString["code"] != null)
            code = Request.QueryString["code"];
           var result = _fb.Post("oauth/access_token",
                                  new
                                  {
                                      client_id = AppId,
                                      client_secret = Appsecret,
                                      redirect_uri = RedirectUri,
                                      code = code,
                                      scope = Scope,
                                      response_type="token"
                                  });

获得长期访问令牌

var result1 = _fb.Post(“oauth / access_token”,new {client_id = AppId,client_secret = Appsecret,grant_type =“fb_exchange_token”,fb_exchange_token = Session [“fb_access_token”] as string});

获取页面访问令牌

dynamic accounts = _fb.Get("me/accounts");

使用页面访问令牌将应用程序添加到页面

var sResult = _fb.Post("<PAGE-ID>/tabs",
                                                    new
                                                    {
                                                        app_id = AppId,
                                                        access_token = <PAGE ACCESS TOKEN>,
                                                        scope = Scope
                                                    });

1 回答

  • 0

    您的评论似乎是在试图将“应用”发布到网页上 - 这是不可能的 . 您需要使用从页面管理员检索到的页面访问令牌进行发布,并且此页面访问令牌允许您代表页面发布帖子 . 应用无法发布'自己' .

相关问题