Facebook UI 消息好友对话框
大家好,只是想知道您是否可以提供帮助,我有一个 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>
提前致谢。
Hi Guys just wondering if you could help, I have a page in C# that should when a button is clicked show the friends dialog to send an information out to them to start using an application.
However I'm having a problem with FB.UI trying to get a modal iframe displaying of the friends list.
Basically it attempts to open the modal iframe it shows the blue facebook frame but no data then after 5 seconds it closes.
can any one help
<%@ 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>
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我测试这段代码时,看起来您的按钮正在执行回发。所以我改为
这
阻止了回发的发生,但对话框从未填充,就像您在帖子中提到的那样。
我不知道为什么,但看起来 Facebook 不喜欢你的测试函数中的 return false,所以我尝试了这个
,并在测试函数中我注释掉了 retrun false。
这有效,但填充速度非常慢。经过一些测试后,速度缓慢似乎是由于函数测试所在的脚本部分位于 asp 表单内,并且在此页面上我有一个脚本管理器,因此我将该脚本部分移到了表单之外,并且填充速度更快了一些。
希望这有帮助
干杯
When I tested this code it looks like your button is doing a postback. so I changed
to
This stoped the postback from happening but the Dialog never populated just like you mentioned in your post.
I am not sure why but it looks like Facebook does not like the return false in your test function so I tried this
and in the test function I commented out the retrun false.
This worked but it was very slow to populate. After some testing it looks like the slowness was dew to the Script section that the function test was in was inside the asp form and on this page I had a script manager so I moved that script section outside the form and it populated a bit faster.
Hope this helps
Cheers