使用C#(Facebook)发布到页面 [英] Posting to Page as Page using C# (Facebook)

查看:346
本文介绍了使用C#(Facebook)发布到页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经取得了一些进展感谢这个页面: Facebook错误(#200)用户尚未授权应用程序执行此操作

I've made some progress thanks to this page: Facebook Error (#200) The user hasn't authorized the application to perform this action

但是,当发布为页面时,我现在已经迷失了。从评论中我看到我需要$ /

However, I'm now lost when it comes to posting as a page. From the comments, I see that I need to


...通过授予自己manage_pages权限并获取页面令牌来获取页面访问令牌从API调用到/ me / accounts(使用最后一次调用的用户令牌)

... 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)

code> 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? And once I get the page token, do I just simply use that token instead and leave my code as it stands?

代码如下:

        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;
        }


推荐答案


我已经去了自己的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?

你使用API​​,我假设在C#SDK中有一个等价的调用,用于 app.Post 作为 app.Get 。看到这是一个个人应用程序,您可以再次使用开发人员工具,从下拉列表中选择您的应用程序,自行为您授予 manage_pages 权限,然后调用 /我/帐户

You use the API, I'm assuming there is an equivalent call in the C# SDK for app.Post as 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

页面的页面标记应该在结果中。

The page token for your page should be there in the result.

您也可以直接通过调用 PAGE_ID?fields = access_token

You can also directly get it via a call to PAGE_ID?fields=access_token

这篇关于使用C#(Facebook)发布到页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆