首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Facebook UI消息好友对话框

Facebook UI消息好友对话框
EN

Stack Overflow用户
提问于 2011-03-02 03:09:13
回答 1查看 1K关注 0票数 0

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

然而,我在尝试获取一个显示朋友列表的模式iframe时遇到了FB.UI的问题。

基本上,它尝试打开模式iframe,它显示蓝色的facebook框架,但没有数据,然后在5秒后关闭。

有谁能帮忙吗?

代码语言:javascript
运行
复制
    <%@ 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>

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-03-11 02:49:24

当我测试这段代码时,它看起来像是你的按钮在做回发。所以我改变了

代码语言:javascript
运行
复制
<asp:Button runat="server" ID="btntest" OnClientClick="Javascript:test();"/>

代码语言:javascript
运行
复制
<asp:Button runat="server" ID="btntest" OnClientClick="return test();"/>

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

我不知道为什么,但看起来Facebook不喜欢你的测试函数中的返回false,所以我试了一下

代码语言:javascript
运行
复制
<asp:Button runat="server" ID="btntest" OnClientClick="Javascript:test();return false;"/>

在test函数中,我注释掉了retrun false。

代码语言:javascript
运行
复制
//return false; 

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

希望这能有所帮助

干杯

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5159145

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档