如何在Facebook上分享多张图片?以下代码段仅共享一个图像。如何修改此代码以满足多个图像?
var fb = new FacebookClient();
fb.AccessToken = strToken
fb.AppId = strAppID
fb.AppSecret = strAppSecret
dynamic parameters = new ExpandoObject();
parameters.title = strTitle;
parameters.message = strDescription;
parameters.source = new FacebookMediaObject
{
ContentType = "image/jpeg",
FileName = Path.GetFileName("myimage")
}.SetValue(System.IO.File.ReadAllBytes(@"C:\Pictures\image1.jpg"));
var result = fb.Post("me/photos", parameters);
}
答案 0 :(得分:0)
使用此代码在Facebook上上传多个图片,
FacebookClient fb = new FacebookClient(token.Trim());
//Perform upload
var imageStream = File.OpenRead(photo.Location);
fb.PostCompleted += (o, e) =>
{
imageStream.Dispose();
if (e.Cancelled || e.Error != null)
{
error = e.Error == null ? "canceled" : e.Error.Message;
}
};
dynamic res = fb.PostTaskAsync("/" + fbAlbumID + "/photos", new
{
message = String.Empty,
file = new FacebookMediaStream
{
ContentType = "image/jpg",
FileName = Path.GetFileName(photo.Location)
}.SetValue(imageStream)
});
res.Wait();
var dictionary = (IDictionary<string, object>)res.Result;
但每次上传的照片都会生成一个弹出式通知。 通过this问题。