简体   繁体   English

如何使用从我的facebook帐户创建的Facebook应用程序密钥从我的网站发布到我的facebook页面上?

[英]How to post on my facebook page from my website using Facebook App keys created from my facebook account?

Below is the code i am using to achieve this functionality, and i have successfully posted it to my facebook wall from my website but i am not able to post to my facebook page? 以下是我用于实现此功能的代码,我已经成功地将其从我的网站发布到了我的Facebook墙,但是我无法发布到我的Facebook页面?

How can i get page access token using FaceBookClient() in c# SDK? 如何在c#SDK中使用FaceBookClient()获取页面访问令牌?

var client = new FacebookClient();

                    dynamic token = client.Get("oauth/access_token", new
                    {
                        client_id = ConfigurationManager.AppSettings["FacebookAPI"].ToString(),
                        client_secret = ConfigurationManager.AppSettings["FacebookAPIKey"].ToString(),
                        grant_type = "client_credentials"
                    });
                    client.AccessToken = token.access_token;

                    dynamic parameters = new ExpandoObject();
                    parameters.title = detail.Title;
                    parameters.message = GetDescription(detail.Description, detail.Content);
                    parameters.link = "http://test.com/blog" + detail.RelativeLink;//HttpContext.Current.Request.IsLocal ? "http://test.com/blog" + detail.RelativeLink : HttpContext.Current.Request.Url.Authority + "" + detail.RelativeLink;

                    var result = client.Post(ConfigurationManager.AppSettings["FacebookPageID"].ToString() + "/feed", parameters);

Please read the docs at 请阅读以下文档

It's clear that you can't use an App Access Token for posting to a Page, because a Post always needs to be related to a profile. 很明显,您不能使用App Access令牌来发布到页面,因为发布始终需要与个人资料相关。

  • A user access token with publish_actions permission can be used to publish new posts on behalf of that person. 具有publish_actions权限的用户访问令牌可用于代表该人发布新帖子。 Posts will appear in the voice of the user. 帖子将出现在用户的声音中。
  • A page access token with publish_pages permission can be used to publish new posts on behalf of that page. 具有publish_pages权限的页面访问令牌可用于代表该页面发布新帖子。 Posts will appear in the voice of the page. 帖子将出现在页面的声音中。

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

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