facebook iframe - 获取 facebook 徽标而不是弹出身份验证
(使用服务器端流程)我有一个 Facebook 应用程序,通过其中一个选项卡附加到 Facebook 页面,这使得该应用程序位于 iframe 内。我使用下面的代码来获取访问令牌,但仅当用户单击 facebook 徽标并验证应用程序时。我的问题是我应该做什么才能获得更好的用户体验而不是显示 Facebook 徽标内容。 谢谢。
ON pageLoad()...... protected void Page_Load(对象发送者,EventArgs e) { 字符串代码 = Request.QueryString["code"]; if (HttpContext.Current.Session["fbAccessToken"] != null) { authToken = HttpContext.Current.Session["fbAccessToken"].ToString(); }
if (!String.IsNullOrEmpty(authToken))
{
thisUserFBID.Value = HttpContext.Current.Session["fbUserId"].ToString();
}
else if (code == "" || code == null)
{
Response.Redirect(appHelp.GetCodeUrl());
//Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "shareMe();", true);
}
else
{
authToken = appHelp.GetAccessToken(code);
Session["access_token"] = authToken;
HttpContext.Current.Session["fbAccessToken"] = authToken;
try
{
var fb = new FacebookClient();
fb.AccessToken = authToken;
dynamic me = fb.Get("me");
thisUserFBID.Value = (string)me.id;
HttpContext.Current.Session["fbUserId"] = thisUserFBID.Value;
if (me.locale != null)
lang = (string)me.locale;
else
lang = "en_US";
HttpContext.Current.Session["lang"] = lang;
}
catch (Exception)
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "shareMe();", true);
//Response.Redirect(appHelp.GetCodeUrl());
}
}
}
(using server-side flow) i have a facebook application that is attached to a facebook page through one of the tabs, which makes the application within an iframe. i use the following code below which works to get the access token but only when the users click on the facebook logo and authenticate the app. my question is what should i do so i can get a better user experience instead of showing the facebook logo stuff.
thanks.
ON pageLoad()......
protected void Page_Load(object sender, EventArgs e)
{
string code = Request.QueryString["code"];
if (HttpContext.Current.Session["fbAccessToken"] != null)
{
authToken = HttpContext.Current.Session["fbAccessToken"].ToString();
}
if (!String.IsNullOrEmpty(authToken))
{
thisUserFBID.Value = HttpContext.Current.Session["fbUserId"].ToString();
}
else if (code == "" || code == null)
{
Response.Redirect(appHelp.GetCodeUrl());
//Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "shareMe();", true);
}
else
{
authToken = appHelp.GetAccessToken(code);
Session["access_token"] = authToken;
HttpContext.Current.Session["fbAccessToken"] = authToken;
try
{
var fb = new FacebookClient();
fb.AccessToken = authToken;
dynamic me = fb.Get("me");
thisUserFBID.Value = (string)me.id;
HttpContext.Current.Session["fbUserId"] = thisUserFBID.Value;
if (me.locale != null)
lang = (string)me.locale;
else
lang = "en_US";
HttpContext.Current.Session["lang"] = lang;
}
catch (Exception)
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "shareMe();", true);
//Response.Redirect(appHelp.GetCodeUrl());
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊?您不想让用户知道他们正在登录什么?我很困惑。在页面选项卡应用程序中,您可以提示他们授权应用程序,或者如果他们已经登录,则向他们展示好东西。我不知道还有什么比这能带来更好的用户体验。
Huh? You don't want to have the user know what they're logging into? I'm confused. In a page tab application, you can either prompt them for authorizing the app or if they're logged in already, show them the good stuff. I don't know what would make a better user experience than that.