I've built a few facebook apps using the c# sdk. and using code below to check if the user has liked the fan page and showing content to reflect that.
protected void Page_Load(object sender, EventArgs e)
{
if (Session["SignedRequest"] != null)
{
signedRequest = Session["SignedRequest"].ToString();
}
else
{
signedRequest = Request.Form["signed_request"];
}
if (!string.IsNullOrEmpty(signedRequest))
{
dynamic SignedRequestData;
var DecodedSignedRequest = FacebookWebContext.Current.SignedRequest.Data;
SignedRequestData = DecodedSignedRequest
var RawRequestData = (IDictionary<string, object>)SignedRequestData;
foreach (KeyValuePair<string, object> paird in RawRequestData)
{
Response.Write("key =" + paird.Key.ToString() + " value =" + paird.Value.ToString() + "<br/>");
}
if (RawRequestData.ContainsKey("page"))
{
Facebook.JsonObject RawPageData = (Facebook.JsonObject)RawRequestData["page"];
if (RawPageData.ContainsKey("liked"))
{
if (bool.Parse(RawPageData["liked"].ToString()))
{
LikedContent.Visible = true;
if (!IsPostBack)
{
PageSetup();
}
}
else
{
UnlikedContent.Visible = true;
}
}
else
{
UnlikedContent.Visible = true;
}
}
else
{
DefaultContent.Visible = true;
}
}
else
{
DefaultContent.Visible = true;
}
}
The problem with this is that if i have multiple pages on the app i get cross domain issues. can fix this quite easily for ie using the p3p header in the gloabl.asac.cs file. the issue however still remains in safari.
Now that the current version 6 of the c# sdk recommends using the facebook javascript sdk to call the open graph and check that the user likes a page and then pass it to the code behind i was wanting to know what actually is the best practice for building facebook fan page tab apps?
When ever i access the users information using the javascript sdk i get a pop up box to authorise the app. i don't want this. is there a way round this?
cheers
You can call graph api method like this in code behind