我正在尝试使用C#Facebook SDK将IsolatedStorage(Windows Phone 7)中的图像上传到Facebook。
这是我目前的代码:
const string fileName = "image.jpg";
IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
if (myIsolatedStorage.FileExists(fileName))
{
IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(fileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
var photo = new WriteableBitmap(0, 0).LoadJpeg(fileStream);
//photo.SetSource(fileStream);
var mediaObject = new FacebookMediaObject
{
FileName = fileName,
ContentType = "image/jpeg",
};
mediaObject.SetValue(photostream?);
}
var settings = IsolatedStorageSettings.ApplicationSettings;
var parameters = new Dictionary<string, object>
{
{ "message", "the message" },
{ "link", "" },
{ "picture", "mediaobject.IMAGEHERE!" },
{ "name", "the name" },
{ "caption", "the caption" },
{ "description", "the descrption" },
{ "privacy", new Dictionary<string, object>
{
{ "value", "ALL_FRIENDS" }
}
}
};
fb.PostAsync("me/feed", parameters, HttpMethod.Post);
这显然不起作用..我需要知道如何将IsolatedStorage中的图像转换为我可以发送到Facebook的格式..
任何帮助都会很棒,如果您还需要其他任何帮助,请直接询问。
谢谢,
迈克尔
答案 0 :(得分:0)
只需将参数数组中的“图片”更改为“source”,我认为它可以正常工作