How can I use the Facebook C# SDK to post on Facebook Pages

我只是一个虾纸丫 提交于 2019-12-17 19:27:08

问题


I have already requested and gained access to 'manage_pages' and 'publish_stream' permissions from a user. How can I use the c# SDK to get permission to post to one of that user's Business Pages wall (They must select one if they Admin multiple Pages, right?). Once I have that access, what is the best method to use the SDK to post to the Business Page wall?

On a related note, can the C# SDK run under ASP.NET 3.5 effectively? Rackspace Cloud Sites is not allowing .NET 4.0 on production servers yet, so I need to see code examples that don't use the 'dynamic' or 'ExpandoObject' keywords.

Thanks!


回答1:


following is the code if it helps you

FacebookApp fbApp = new FacebookApp();
FacebookApp app = new FacebookApp(fbApp.Session.AccessToken);
var args = new Dictionary<string, object>();
args["message"] = "abc";
args["caption"] = "This is caption!";
args["description"] = "This is description!";
args["name"] = "This is name!";
args["picture"] = "[your image URL]";
args["link"] = "[your link URL]";

app.Api("/me/feed", args, HttpMethod.Post);

You need to replace /me in app.Api's arguments to the specific id of page. I'm not sure if its the right way, but it works for wall post of a user :-)




回答2:


Here's how with c# SDK 5.1.1

FacebookClient fbClient = new FacebookClient(accessToken);
var args = new Dictionary<string, object>();
args["message"] = "Testing 123";
fbClient.Post("/me/feed", args);



回答3:


args["picture"] = "[your image URL]";
args["link"] = "[your link URL]";

The image url and link won't work if you give a localhost address.You can try by giving url of an image in a remote server.



来源:https://stackoverflow.com/questions/4361561/how-can-i-use-the-facebook-c-sharp-sdk-to-post-on-facebook-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!