2011-03-01 27 views
0

嗨,大家只是想知道你是否可以提供幫助,我有一個C#頁面,當點擊一個按鈕時,顯示朋友對話框向他們發送信息以開始使用應用程序。Facebook的用戶界面消息朋友對話

但是,我有一個問題,FB.UI試圖獲取模式iframe顯示的朋友列表。

基本上它試圖打開模式iframe,它顯示藍色臉譜框但沒有數據,然後5秒鐘關閉。

任何一個可以幫助

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Main.master" AutoEventWireup="true" CodeFile="CompetitionPanel.aspx.cs" Inherits="CompetitionPanel" %> 

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> 
    <script src="http://connect.facebook.net/en_US/all.js"></script> 
    <script> 
     FB.init({ 
      appId: '123', 
      status: true, // check login status 
      cookie: true, // enable cookies to allow the server to access the session 
      xfbml: true, // parse XFBML 
      session: '<%=CurrentSession.AccessToken %>' 
     }); 
    </script> 
</asp:Content> 
<asp:Content ID="Content2" ContentPlaceHolderID="body" Runat="Server"> 
<script> 

    function test() { 
     FB.ui({method: 'apprequests', 
     message: 'You should learn more about this awesome game.', 
     data: 'tracking information for the user', 
     display: 'iframe' 
    }, 
    function (response) { 
     if (response && response.post_id) { 
      alert('Post was published.'); 
     } else { 
      alert('Post was not published.'); 
     } 
    } 

    ); 

     return false; 
    } 

</script> 
<div id="fb-root"></div> 
<div class="container"> 
    <div class="left"> 
     <h2>WANT TO WIN FREE KIT?</h2> 
     <p> 
      Suggest your friends. At the end of the week, you'll be entered into a prize draw to win free kit. The competition resets every week. 
      Simple. 
     </p> 
     <asp:Button runat="server" ID="btntest" OnClientClick="Javascript:test();"/> 
    </div> 
    <div class="right"></div> 
</div> 
</asp:Content> 

在此先感謝。

+0

你對你在你的Facebook應用程序設置(網站網址)相同的URL運行示例? – 2011-03-07 01:07:15

回答

2

當我測試此代碼時,它看起來像您的按鈕正在做回發。所以我改變

<asp:Button runat="server" ID="btntest" OnClientClick="Javascript:test();"/> 

<asp:Button runat="server" ID="btntest" OnClientClick="return test();"/> 

該採空回發發生,但該對話框從未填充就像你在你的文章中提到。

我不知道爲什麼,但它看起來像Facebook不喜歡你的測試函數返回false,所以我想這

<asp:Button runat="server" ID="btntest" OnClientClick="Javascript:test();return false;"/> 

,並在測試功能我註釋掉retrun假的。

//return false; 

這工作,但它填充非常緩慢。經過一些測試,看起來腳本部分露出的緩慢,功能測試是在asp窗體內部,並且在這個頁面上我有一個腳本管理器,所以我將該腳本部分移到了窗體之外,並且它的填充速度更快一些。

希望這有助於

乾杯

相關問題