简体   繁体   English

使用C#将页面发布为页面(Facebook)

[英]Posting to Page as Page using C# (Facebook)

I've made some progress thanks to this page: Facebook Error (#200) The user hasn't authorized the application to perform this action 感谢此页面,我已经取得了一些进展: Facebook错误(#200)用户未授权应用程序执行此操作

However, I'm now lost when it comes to posting as a page. 但是,现在我以页面发布的方式迷路了。 From the comments, I see that I need to 从评论中,我看到我需要

... get a page access token by granting yourself manage_pages permission and getting the page token from an API call to /me/accounts (using the user token with the last call) ...通过授予您自己的manage_pages权限并从API调用/ me / accounts获取页面令牌来获得页面访问令牌(在最后一次调用中使用用户令牌)

I've gone and granted myself manage_pages permission but how do I make an API call to /me/accounts to get the page token? 我已经离开并授予了自己manage_pages权限,但是如何对/me/accounts进行API调用以获取页面令牌? And once I get the page token, do I just simply use that token instead and leave my code as it stands? 一旦获得页面令牌,我是否只是简单地使用该令牌,而将代码保持原样?

Code below: 代码如下:

        var pageId = facebookPageId;

        var app = new FacebookClient();
        app.AccessToken = facebookAccessToken; // copied from Graph Explorer

        dynamic messagePost = new ExpandoObject();
        messagePost.access_token = facebookAccessToken; // copied from Graph Explorer
        messagePost.link = "www.google.com";
        messagePost.name = "some name";
        messagePost.caption = "{test actor} " + "Test message"; //<---{*actor*} is the user (i.e.: Aaron)
        messagePost.description = "Test description";

        try {
            var result = app.Post("/" + pageId + "/feed", messagePost);
        } catch (FacebookOAuthException ex) {
            var test = ex;
        } catch (FacebookApiException ex) {
            var test = ex;
        }

I've gone and granted myself manage_pages permission but how do I make an API call to /me/accounts to get the page token? 我已经离开并授予了自己manage_pages权限,但是如何对/ me / accounts进行API调用以获取页面令牌?

You use the API, I'm assuming there is an equivalent call in the C# SDK for app.Post as app.Get . 您使用API​​,我假设在C#SDK中有一个等效的调用app.Post作为app.Get Seeing that this is a personal app, you can just use the developer tool again, select your app from the dropdown, grant yourself manage_pages permissions then call /me/accounts 看到这是一个个人应用程序,您可以再次使用开发人员工具,从下拉列表中选择您的应用程序,为自己授予manage_pages权限,然后调用/me/accounts

页面令牌

The page token for your page should be there in the result. 页面的页面令牌应该在结果中。

You can also directly get it via a call to PAGE_ID?fields=access_token 您也可以通过调用PAGE_ID?fields=access_token直接获取它

特定页面令牌

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

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