Post to wall fail when a picture is added
I've managed to post to a user wall, but when i try to add a picture to the parameters of the post, the post fails and the Result is null. I think that i´m doing everything alright, but i could use some help. Thanks in advance!
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
{
}
});
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);
精彩评论