0

我正在尝试使用图形 api 更新我的页面应用程序图像,但没有任何反应。我有正确的访问令牌,我可以更改 custom_name 但不能更改 custom_image。

                    var fbdc = new Dictionary<string, object>();
                    fbdc.Add("access_token", AccessToken);
                    fbdc.Add("custom_name", Name);
                    fbdc.Add("custom_image",Image);
                    result = fb.Post(tab.id, fbdc);

我从图形 api 得到结果为真,但图像仍然没有改变。我的图像是 111*74.jpg。我能够手动上传相同的图像,但不能通过图形 API。难道我做错了什么 ?

4

1 回答 1

0
var fbparams = new Dictionary<string, object>();
          string path = @"c:\test.jpg";
          FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
      var picture = new FacebookMediaObject
                {
                        //Tell facebook that we are sending image
                    ContentType = "image/jpeg",
                    //Give name to the image
                    FileName = "test"
                };
                //Create a new byteArray with right length
                var img = tabImageInfo.Media;
                //Convert the image content into bytearray
               fs.Read(img, 0, img.Length);
                 //Close the stream
               fs.Close();
                //Put the bytearray into Picture
                picture.SetValue(img);
                //Add the image into parameters
                fbparams.Add("custom_image", picture);
        fb.Post(tab.id, fbparams);
于 2013-11-13T00:42:34.093 回答