2012-12-02 45 views
0

我試圖開發應用程序,它會拍攝一張照片並將其發送到我的Facebook粉絲頁面。嘗試了很多不同的方式來做到這一點,但最多隻能共享一條消息,如果我嘗試發佈圖片,那麼它會發布在我的時間軸上,而不是我的粉絲頁面。所以問題是:如何在Facebook粉絲頁上發佈圖片

  • 如何上傳圖片和消息到Facebook頁面(如果可能的話)?

這是使用後的代碼我'的一部分:

using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) 
      { 
       using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(fileName, FileMode.Open, FileAccess.Read)) 
       { 
        WriteableBitmap LoadedPhoto = new WriteableBitmap(0,0); 
        using (MemoryStream ms = new MemoryStream()) 
        { 
         LoadedPhoto.SetSource(fileStream); 
         LoadedPhoto.SaveJpeg(ms, LoadedPhoto.PixelWidth, LoadedPhoto.PixelHeight, 0, 95); 
         ms.Seek(0, 0); 
         byte[] data = new byte[ms.Length]; 
         System.Diagnostics.Debug.WriteLine(LoadedPhoto.PixelWidth); 
         ms.Read(data, 0, data.Length); 
         ms.Close(); 
         var fbUpl = new Facebook.FacebookMediaObject 
         { 
          FileName = fileName, 
          ContentType = "image/jpg" 
         }.SetValue(data); 
         var parameters = new Dictionary<string, object>(); 
         parameters["message"] = message; 
         parameters["file"] = fbUpl; 

         fb.PostAsync("{pageID}/photos", parameters, "post"); 
        } 
       } 
      } 

預先感謝您。

回答

0

確保您在發佈時使用Page Access Token。這是API知道你想充當頁面而不是登錄用戶的唯一方式。

+0

謝謝,但我還有一個問題。我如何讓普通用戶在我的粉絲頁面牆上發佈圖片?它甚至有可能做到這一點? –

+0

使用消息參數和發佈用戶的'access_token'對'/ /feed'進行HTTP POST。更多細節[這裏](https://developers.facebook.com/docs/reference/api/post/) –

相關問題