2011-03-23 55 views
0

我有一個Facebook應用程序設置應用程序在iFrame中運行的位置。該iFrame只包含一個包裝Silverlight應用程序的index.html。如何通過iFrame中的Facebook內部運行的Silverlight應用程序發佈到Facebook上的用戶牆?

這一切都運行良好,但我現在希望能夠從Silverlight應用程序內部發布到用戶的牆上。在我看來,像有可能是兩種方式我可以這樣做:

  1. 使用的Silverlight的Facebook SDK產卵子瀏覽器頁面,驗證檢索令牌,然後發佈到把東西在牆上
  2. 我認爲必要的應用令牌傳遞給我的Silverlight控件,然後從控制回調(成JavaScript?)包裝的index.html做發佈

第二個看起來像一個更具吸引力的選擇,但首先是我知道該怎麼做的唯一一個。任何人都有更好的經驗/想法嗎?

克里斯

回答

0

你可以做些什麼像這樣在你的頁面:

<script> 
FB.getLoginStatus(function(response) { 
    if (response.session) { 
    // Substitute with the proper stuff in your silverlight app 
    mySilverlightFBApp.setFBSessionStuff(
      response.session.access_token, 
      response.session.expires, 
      response.session.uid 
    ); 
    } 
}); 
</script> 

會話對象中有其他字段(但不知道你想這樣做)。順便說一句,getLoginStatus函數不記錄用戶,只檢查其狀態。由於他們(大概)使用你的應用程序,並且(也可能)允許應用程序,這應該是正常的。 (你需要讓他們登錄並允許應用程序..你可能需要請求權限..在這種情況下,你想發佈到他們的飼料)。您的索引頁面還需要包含FB Javascript(並正確設置)。

查看這裏的FB文檔以獲取更多信息:http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/

0

也許: 3)使用Facebook的JavaScript SDK讓用戶發佈流自己的故事?如果你已經得到了fb.init功能等所有設置,然後只需調用(像)這(在底部的部分是跟蹤的帖子,如果你想):

FB.ui(
     { 

      display:'iframe', 
      method: 'stream.publish', 
      caption: 'blah', 
      description: 'hey there. wow., 
      name: 'yo', 
      link: 'http://foo.com', 
      picture: 'http://image.com/blah.gif', 
      action_links: [ 
         { 
         text: 'Try for free', 
         href: 'http://foo.com' 
         }], 



     }, 
      function (response) { 
       if (response && response.post_id) { 
       var URL = '/pages/ajax_InsertUserFacebookPost.aspx?'; 
       URL += 'facebookpostid=' + response.post_id; 
       //alert(URL); 
       $.ajax({ 
         type: "GET", 
         url: URL, 
         data: "{}", 
         contentType: "application/json; charset=utf-8", 
         dataType: "json", 
         async: true 
        }); 


       } else { 
        //alert('Post was not published.'); 
       } 
      } 
      ); 
相關問題