Simplest way to post to a facebook fan page#39;s wall with C#!(使用 C# 发布到 facebook 粉丝页面墙上的最简单方法!)
问题描述
我为我的公司设置了一个粉丝页面.
I have a fan page setup for my company.
我想从我的 C# 桌面应用程序自动将定期更新发布到该页面的墙上.
I want to automate the posting of regular updates to that page's wall from my C# desktop application.
哪个 Facebook C# 库最简单?
Which Facebook C# library is the simplest?
如何轻松获取此页面的访问令牌?
How can I easily acquire the access token for this page?
什么是最简洁的代码片段,可以让我发布到墙上?
What is the most concise code snippet that will simply allow me to then post to the wall?
我已经阅读了所有文档以及数百万的 stackoverflow 和博客文章,这一切似乎都非常令人费解.当然不会那么难..
I have read through all the docs and millions of stackoverflow and blog posts and it all seems very convoluted. Surely it can't be that hard..
我在 facebook 中设置了一个应用程序",它有自己的 App ID、API Key 和 App Secret 等.
I have setup an "application" within facebook that has its own App ID, API Key and App Secret etc.
推荐答案
@Aaron - 最好的库是 facebook c# sdk.我每天都在使用它……当然,正如我的公司所写的那样,我有偏见 - 但它是一个动态库,而且 Facebook 的更新速度(每周二)非常适合可扩展的开发.
@Aaron - the best library is the facebook c# sdk. I use it every day... granted I am biased as my company writes it - but it's a dynamic library and with the rate of updates from Facebook (every Tuesday) it is well suited for scalable development.
http://facebooksdk.codeplex.com/
我不会使用它进行身份验证 - 因为在 codeplex 上有很多示例:http://facebooksdk.codeplex.com/wikipage?title=Code%20Examples&referringTitle=Documentation一>但是要在页面上发布帖子,在您通过身份验证并获得访问令牌后,代码将是这样的:
I won't get into authentication with it - as on codeplex there are many examples: http://facebooksdk.codeplex.com/wikipage?title=Code%20Examples&referringTitle=Documentation But to do a post to a page, after you have authenticated and have an access token, the code would be something like this:
dynamic messagePost = new ExpandoObject();
messagePost.access_token = "[YOUR_ACCESS_TOKEN]";
messagePost.picture = "[A_PICTURE]";
messagePost.link = "[SOME_LINK]";
messagePost.name = "[SOME_NAME]";
messagePost.caption = "{*actor*} " + "[YOUR_MESSAGE]"; //<---{*actor*} is the user (i.e.: Aaron)
messagePost.description = "[SOME_DESCRIPTION]";
FacebookClient app = new FacebookClient("[YOUR_ACCESS_TOKEN]");
try
{
var result = app.Post("/" + [PAGE_ID] + "/feed", messagePost);
}
catch (FacebookOAuthException ex)
{
//handle something
}
catch (FacebookApiException ex)
{
//handle something else
}
希望这会有所帮助.
这篇关于使用 C# 发布到 facebook 粉丝页面墙上的最简单方法!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 C# 发布到 facebook 粉丝页面墙上的最简单方法
基础教程推荐
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- c# Math.Sqrt 实现 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- rabbitmq 的 REST API 2022-01-01