本文介绍了如何在我的Facebook应用程序页面中获取页面ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序作为选项卡托管在FaceBook中,当添加应用程序以存储在逻辑中时,我想获取页面ID.我如何获取页面ID,我知道它存储在URL中,但是当我尝试从页面中将它作为服务器变量获取时,即使我的应用程序配置为iFrame
,也无法获取它?但这是获取父URL的标准方法.
I have my application is hosted in FaceBook as a tab and I want to get the page ID when my application is being added to be stored in my logic.How can I get the page ID, I know it is stored in the URL but when I tried to get it from the page as a server variable, I am not getting it even my application is configured as iFrame
? But this is a standard way to get the parent URL.
C#:
string t= request.serverVariables("HTTP_REFERER");
//doesn't get FB page url even if your app is configured as iframe ?!! @csharpsdk #facebook devs
有帮助吗?
非常感谢.
推荐答案
这是我的方法:
if (FacebookWebContext.Current.SignedRequest != null)
{
dynamic data = FacebookWebContext.Current.SignedRequest.Data;
if (data.page != null)
{
var pageId = (String)data.page.id;
var isUserAdmin = (Boolean)data.page.admin;
var userLikesPage = (Boolean)data.page.liked;
}
else
{
// not on a page
}
}
这篇关于如何在我的Facebook应用程序页面中获取页面ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!