Facebook UI消息朋友对话

时间:2011-03-01 19:09:13

标签: facebook facebook-c#-sdk fbjs

嗨大家只是想知道你是否可以提供帮助,我在C#中有一个页面应该在点击按钮时显示朋友对话框,向他们发送信息以开始使用应用程序。

但是我遇到了FB.UI尝试获取朋友列表的模态iframe的问题。

基本上它试图打开模态iframe它显示蓝色的facebook框架,但没有数据然后在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>

提前致谢。

1 个答案:

答案 0 :(得分: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 false。

//return false; 

这很有用,但填充的速度很慢。经过一些测试后,看起来像脚本部分的缓慢是函数测试所在的内容是在asp表单内部,在这个页面上我有一个脚本管理器,所以我将脚本部分移到表单之外,它填充的速度更快一些。

希望这有帮助

干杯