我正在使用Facebook C# SDK。
问题:
'是张贴照片,但不是“标签”
public JsonResult PostFacebookTagPhoto()
{
var path = Request["url"];
var tag = Request["tags"];
var facebookClient = new FacebookClient(Session["facebook.accessToken"].ToString());
var file = new FileInfo(path);
var data = System.IO.File.ReadAllBytes(file.FullName);
var stream = System.IO.File.OpenRead(path);
try
{
var itens = JsonHelper.JsonDeserialize<List<TagFacebook>>(tag);
dynamic me = Session["facebook.me"];
var tags = new[]
{
new { itens[1].tag_uid, x = 30, y = 40},
new { itens[2].tag_uid, x = 40, y = 50},
new { itens[3].tag_uid, x = 30, y = 40},
new { itens[4].tag_uid, x = 40, y = 50},
new { tag_uid = (string)me.id, x = 50, y = 40}
};
dynamic parameters = new ExpandoObject();
parameters.message = GetFacebookMessage();
parameters.tags = tags;
parameters.file = new FacebookMediaObject
{
ContentType = MimeTypes.GetMimeType(file.Extension.ToLowerInvariant()),
FileName = file.Name.ToLowerInvariant()
}.SetValue(data);
try
{
facebookClient.Post("/me/photos", parameters); //LINE 133
}
catch (FacebookApiException ex)
{
return new JsonResult { Data = new { status = "error", message = ex.Message, source = ex.Source, stacktrace = ex.StackTrace }, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
//SalvaDados(me, itens);
return new JsonResult { Data = new { status = "ok" }, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
catch (FacebookOAuthException ex)
{
return new JsonResult { Data = new { status = "error", message = ex.Message }, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
}
错误消息:
(异常 - #1399017)抱歉,发生错误。请再试一次。
堆栈跟踪:
在 Facebook.FacebookClient.ProcessResponse(HttpHelper httpHelper, String responseString, Type resultType, Boolean containsEtag, IList`1 batchEtags)
在 Facebook.FacebookClient.Api(HttpMethod httpMethod, String path, Object parameters, Type resultType)
在 Facebook.FacebookClient.Post(字符串路径,对象参数)
在 (...)\Controllers\SiteController.cs:line 133