简体   繁体   English

Facebook从C#发布到页面

[英]Facebook publish from C# to a page

I have a webapplication with a cms-system. 我有一个带有cms系统的web应用程序。 I have created a task that is executed when someone publish a newsarticle on the page. 我创建了一个任务,当有人在页面上发布新闻文章时执行该任务。 Simple thing. 简单的事情。 What I would like to do is to publish this newsarticle on our Facebook page AS the page. 我想做的是在我们的Facebook页面AS页面上发布这个新闻文章。

There are a lot of old versions of api and stuff out there so I cannot figure out what is the most updated version of doing this. 有很多旧版本的api和东西,所以我无法弄清楚这是做什么最新版本。

Can someone please explain the steps I need to perform to auth an application to post to the page, and how to actually post the message? 有人可以解释我需要执行的步骤来授权应用程序发布到页面,以及如何实际发布消息?

I do not have any userinput options at this point but the most guides I have found requires user input in some auth dialogs and such. 我此时没有任何用户输入选项,但我发现的大多数指南都需要用户输入一些身份验证对话框等。 It must be possible to auth the app, and then request a token and post the page right? 必须可以授权应用程序,然后请求令牌并正确发布页面?

Follow step 1 to 4 here: http://developers.facebook.com/docs/authentication/server-side/ 按照步骤1到4进行操作: http//developers.facebook.com/docs/authentication/server-side/

Make sure you enter 'manage_pages' and 'publish_stream' permission in step 1. This should give you a valid access token. 确保在步骤1中输入“manage_pages”和“publish_stream”权限。这应该为您提供有效的访问令牌。

With this access token, you call the following api method: (replace xxxxxxx with access_token) 使用此访问令牌,您可以调用以下api方法:(用access_token替换xxxxxxx)

https://graph.facebook.com/me/accounts?access_token=XXXXXXXX https://graph.facebook.com/me/accounts?access_token=XXXXXXXX

In the output you should see something similar to this: 在输出中,您应该看到类似于此的内容:

    {
   "data": [
      {
         "name": "My App",
         "category": "Application",
         "id": "10258853",
          "access_token": "yyyyyyyyyyyyyy"
      }
   ]
}

Using the yyyyyyyyyyy access_token you can publish to any wall like you would do as a user. 使用yyyyyyyyyyy access_token,您可以像用户一样发布到任何墙。

https://graph.facebook.com/ThePageId/feed/message=MyFirstPost&access_token=yyyyyyyyyyyyyy https://graph.facebook.com/ThePageId/feed/message=MyFirstPost&access_token=yyyyyyyyyyyyyy

I've been asking the same before. 我之前一直在问同样的问题。 See my question here for the code i was using then. 在这里查看我的问题,我正在使用的代码。 I think you should manage with that and my answer above. 我认为你应该管理上面的答案和我的答案。

I hope i could make at least a few things clear for you. 我希望我至少可以为你做一些事情。 If not, ask me and i'll try to help you out. 如果没有,请问我,我会尽力帮助你。

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

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