2013-10-10 49 views
0

我想用圖表api更新我的頁面應用程序圖像,但沒有任何反應。我有正確的訪問令牌,我可以更改custom_name而不是custom_image。不能更新Facebook頁面的應用程序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。 我做錯了什麼?

回答

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); 
+0

上面的代碼適用於我。 – rakeshvenkata

+0

http://www.tapanila.net/post-picture-into-a-bookbook/供參考 – rakeshvenkata

相關問題