0

我使用了以下代码。图片已成功发布并带有名称,但无法发布消息/描述。请告诉我我错在哪里。它也没有给出任何例外。

 private void SharePhoto(string _accessToken, string p)
    {
        var fb = new FacebookClient(_accessToken);
        fb.PostCompleted += (o, args) =>
            {
                if (args.Error != null)
                {
                    if (args.Error.Message.StartsWith("(OAuthException - #190)"))
                    {
                        Dispatcher.BeginInvoke(() =>
                            { MessageBox.Show("Message Expired"); });
                    }
                    else
                    {
                        Dispatcher.BeginInvoke(() =>
                            { MessageBox.Show(args.Error.Message, "Error", MessageBoxButton.OK); });
                    }
                    return;
                }
                else
                {
                    Dispatcher.BeginInvoke(() =>
                        { MessageBox.Show("Image Posted"); });
                }
            };

        var fbupload = new FacebookMediaObject 
        {
            FileName = "facebook.jpg",
            ContentType = "image/jpeg"
        };
        StreamResourceInfo sri =Application.GetResourceStream(new Uri("facebook.jpg",UriKind.Relative));
        BitmapImage bitmap = new BitmapImage();
        bitmap.SetSource(sri.Stream);
        var loadedImage = new WriteableBitmap(bitmap);
        using (MemoryStream ms = new MemoryStream())
        {

            loadedImage.SaveJpeg(ms, loadedImage.PixelWidth, loadedImage.PixelHeight, 0, 95);
            ms.Seek(0, 0);
            byte[] data = new byte[ms.Length];
            ms.Read(data, 0, data.Length);
            ms.Close();
            fbupload.SetValue(data);
        }

        var parameters = new Dictionary<string, object>();           
        parameters["message"] = txtMessage.Text;
        parameters["description"] = "first ever one";

        parameters["name"] = "My FB Pic";
        parameters["picture"]=fbupload;
        parameters["link"] = new Uri(@"http://www.anyxyz.com", UriKind.Absolute);
        fb.PostAsync(@"me/photos", parameters);

    }

我将扩展权限用作:

 private const string extendedPermissions = "user_about_me,read_stream,publish_stream"; 

任何帮助将不胜感激。

4

0 回答 0