我如何检查是否.POST已经成功地在Facebook的C#SDK送?POST、Facebook、SDK

2023-09-04 22:33:42 作者:劳资、限量版

我尝试使用下面的code发送的消息:

I try send the message using the followingcode:

//... 
FacebookClient fbClient = new FacebookClient(appId, appSecret);
fbClient.AccessToken = "...";
string to = "user id";
dynamic result = fbClient.Post(String.Format("{0}/feed", to), parameters);

但我怎么知道,如果menssage已发送给用户成功?什么是对的情况下成功/错误回报的回报?我没有找到Facebook的SDK,API的文档中的一些细节的C#。

but how I can know if the menssage has send to user successfully? what's the returns on case success/erros? I not found some details in the documentation of facebook-sdk-api for C#.

.NET版本: v4.0.30319

Facebook的大会版本: 5.2.1.0

Facebook Assembly version: 5.2.1.0

在此先感谢。

推荐答案

通过采取基准的 https://developers.facebook.com/docs/reference/rest/stream.publish/  你将不得不为的post_id 结果参数全成呼叫,如果失败,它应该是一些JSON,包括错误信息,例如:

by taking reference https://developers.facebook.com/docs/reference/rest/stream.publish/ you will have post_id for result parameter for successfull call, if fail it should be some json including error message, for example:

{
  "error_code": 200,
  "error_msg": "The user hasn't authorized the application to perform this action",
  "request_args": [
    {
      "key": "method",
      "value": "stream.publish"
    },
    {
      "key": "access_token",
      "value": "AAAC9okD6ZA7ABABhvJOZBQvUE2OsuHLKEkqlvKKkPDNB9kHfF55DqgKF2raHmSaUSgkpvLtgWniM5CFnu5mxaGODLqvwVz9zBNd1Jd6AZDZD"
    },
    {
      "key": "format",
      "value": "json"
    }
  ]
}