我设法发布到用户墙,但是当我尝试将图片添加到帖子的参数时,帖子失败并且结果为空。我认为我做的一切都很好,但我可以使用一些帮助。提前谢谢!
IDictionary<string, object> parameters = new Dictionary<string, object>();
parameters["access_token"] = fbAccessToken;
parameters["name"] = "my picture";
parameters["message"] = "this is a picture uploaded from my the facebook sdk";
parameters.Add("picture", "http://t2.gstatic.com/images?q=tbn:Bebedm7ldqvC3M:http://www.configmac.com/images/logiciel/image.jpg");
fbApp.PostAsync("me/feed", parameters, (val) =>
{
if (val.Error == null)
{
// Asyncronous call, only executed after obtaining Facebook response
var result = (IDictionary<string, object>)val.Result;
}
else
{
}
});
答案 0 :(得分:2)
var picture = File.ReadAllBytes("a.jpg");
var fb = new FacebookClient(_accessToken);
fb.PostCompleted +=
(o, args) =>
{
if (args.Error == null)
{
MessageBox.Show("Picture posted to wall successfully.");
}
else
{
MessageBox.Show(args.Error.Message);
}
};
dynamic parameters = new ExpandoObject();
parameters.caption = txtMessage.Text;
parameters.method = "facebook.photos.upload";
var mediaObject = new FacebookMediaObject
{
FileName = Path.GetFileName(ofd.FileName),
ContentType = "image/jpeg"
};
mediaObject.SetValue(picture);
parameters.source = mediaObject;
fb.PostAsync(parameters);