下面的代码将图像发布到 Facebook 页面。但是,当它失败时(无论出于何种原因),它不会抛出任何异常,因此我无法找出失败的根本原因(只有我提供的一般消息(“无法发布”)。我将如何更改下面的代码显示实际错误?
这是使用 Facebook C# SDK
FacebookClient fbClient = new FacebookClient(accessToken);
fbClient.PostTaskAsync(path, post)
.ContinueWith(task =>
{
if (!task.IsFaulted)
{
if (((IDictionary<string, object>)post).ContainsKey("scheduled_publish_time"))
{
DateTime dateTime = Utilities.ConvertUnixTimeStampToDateTime(Double.Parse((((dynamic)post).scheduled_publish_time)), true);
OnFacebookPostSuccess("Successfully posted: (" +
dateTime + ") " + postText);
}
else
{
OnFacebookPostSuccess("Successfully posted: (" +
DateTime.Now + ") " + postText);
}
}
else
{
OnFacebookPostFailed("Failed to post " + filename);
}
});