问题
Well, I am trying make a app to write comments to facebook in C#. Searching in google I know that I need an Application (I did it) and I need select the permissions. I did it.. Now I wrote my code in C#:
private string MyAppId = "XXX";
private string MyAppSecret = "XXX";
private void button1_Click(object sender, EventArgs e)
{
FacebookClient FB = new FacebookClient(MyAppId, MyAppSecret);
Dictionary<string,string> data = new Dictionary<string,string>();
data.Add("message","test");
FB.Post("OBJECT_ID/comments", data);
}
But when I click the button I get this error:
(OAuthException) (#200) User must have accepted TOS
I am getting crazy! Please help me =(
回答1:
It doesn't look like you're actually using the users access token.
You need to go through the OAuth workflow, where the user is redirected to facebook.com and grants your application permission. Once that happens, you'll get an Access Token that you use to make requests on behalf of the user.
There's an overload for the FacebookClient class that will take an access token.
Since you didn't really expand on the type of app you're writing, the Facebook C# Github page has a collection of samples, for WinForms, ASP.NET, and Windows 8 Metro. This example should show you how to do client-side authentication.
You're also trying to post to OBJECT_ID, which isn't a valid user/post/page.
来源:https://stackoverflow.com/questions/13243286/oauthexception-200-user-must-have-accepted-tos-on-c-sharp-facebook