将图像从Isolated Storage上传到Facebook(WP7)

时间:2011-10-17 16:27:29

标签: windows-phone-7 facebook-c#-sdk

我正在尝试使用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的格式..

任何帮助都会很棒,如果您还需要其他任何帮助,请直接询问。

谢谢,

迈克尔

1 个答案:

答案 0 :(得分:0)

只需将参数数组中的“图片”更改为“source”,我认为它可以正常工作