Facebook C# SDK Sample to Post To Group Wall

冷暖自知 提交于 2019-12-12 03:21:15

问题


Please give a sample of how to post to a group wall using the C# Facebook SDK found at this location https://github.com/facebook-csharp-sdk/facebook-csharp-sdk . Below is just a few lines of relevant code. An fb client is created, parameters filled in (not shown), and a fb.post call is made. For my attempt to post to a group wall, all I did was change the "me/feed" to "groupId/feed". I could probably figure out what is wrong but the Facebook error provides no information. The error returned is "(OAuthException) An unexpected error has occurred. Please retry your request later."

var fb = new FacebookWebClient();

Original SDK Sample Code is: dynamic id = fb.Post("me/feed", parameters);

Attempt to Post to Group is: dynamic id = fb.Post("328271290556233/feed", parameters);

Unfortunately I have not been unable to find an example using the SDK referenced above.

Thank you for any help.


回答1:


After trying multiple attempts, I figured out the problem by trying to post a message to my group using the Facebook Explorer app at http://developers.facebook.com/tools/explorer . It did post and I realized I had granted the application all rights. I then removed all rights and added back one by one. Here is what is interesting, if you are missing the publish_stream right, then a post attempt results in a useful error message stating the application does not have the right to post. If your application has publish_stream but not user_groups, then you get the unknown error. So, to fix my problem all I had to do was have my application ask for the user_groups right. The exact rights I use are user_about_me,user_groups,publish_stream,manage_pages. I hate I missed something so obvious but a helpful error message would have been nice. To post to a group using the SDK just replace "me" with the group id. That is it.



来源:https://stackoverflow.com/questions/9440283/facebook-c-sharp-sdk-sample-to-post-to-group-wall

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