【问题标题】:Facebook UI Message Friend DialogFacebook UI 消息好友对话框
【发布时间】:2011-03-11 02:49:23
【问题描述】:

大家好,只是想知道您是否可以提供帮助,我有一个 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>

提前致谢。

【问题讨论】:

  • 您是否在 Facebook 应用程序中设置的相同 url(站点 url)上运行示例?

标签: facebook facebook-c#-sdk fbjs


【解决方案1】:

当我测试此代码时,您的按钮似乎正在回发。所以我改变了

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

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

这阻止了回发的发生,但对话框从未像您在帖子中提到的那样填充。

我不知道为什么,但看起来 Facebook 不喜欢你的测试函数中的 return false 所以我尝试了这个

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

在测试函数中我注释掉了 retrun false。

//return false; 

这行得通,但填充速度很慢。经过一些测试后,函数测试所在的脚本部分似乎在 asp 表单内,并且在此页面上我有一个脚本管理器,因此我将该脚本部分移到了表单之外,并且填充速度更快。

希望对你有帮助

干杯

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-31
    • 1970-01-01
    • 2011-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-18
    相关资源
    最近更新 更多