Note that there are some explanatory texts on larger screens.

plurals
  1. POFinding out if a Facebook page is liked by a user. Using the Facebook C# SDK
    text
    copied!<p>I'm trying to build a Facebook 'fangate' tab or 'reveal' tab for a Facebook page. </p> <p>You know how it goes - when a user visits the page, they are shown one bit of content if they haven't yet clicked 'Like' and another once they have.</p> <p>I'm not a PHP guy so I'm attempting to do this with the Facebook C# SDK (<a href="http://facebooksdk.codeplex.com" rel="nofollow">http://facebooksdk.codeplex.com</a>) in Visual Studio 2010. I'm fairly new to .NET too so I'm not doing so well with this!</p> <p>I have to admit I've been cutting and pasting code from all over the place to get this to work and I think I'm almost there but I'm not getting this error:</p> <p><strong>Invalid signed request.</strong></p> <p><strong>Line 82: var DecodedSignedRequest = FacebookSignedRequest.Parse(current, FacebookWebContext.Current.SignedRequest.Data.ToString());</strong></p> <p>Here's my code:</p> <pre><code> var settings = ConfigurationManager.GetSection("facebookSettings"); var current = settings as IFacebookApplication; var DecodedSignedRequest = FacebookSignedRequest.Parse(current, FacebookWebContext.Current.SignedRequest.Data.ToString()); dynamic SignedRequestData = DecodedSignedRequest.Data; var RawRequestData = (IDictionary&lt;string, object&gt;)SignedRequestData; string currentFacebookPageID = current.AppId; bool currentFacebookPageLiked = false; if (RawRequestData.ContainsKey("page") == true) { Facebook.JsonObject RawPageData = (Facebook.JsonObject)RawRequestData["page"]; if (RawPageData.ContainsKey("id") == true) currentFacebookPageID = (string)RawPageData["id"]; if (RawPageData.ContainsKey("liked") == true) currentFacebookPageLiked = (bool)RawPageData["liked"]; } if (currentFacebookPageLiked) { //Do some stuff for fans } else { //Do some stuff for non-fans } </code></pre> <p>All the Facebook settings are in my web.config file and I have checked that the AppID and AppSecret are correct.</p> <p>Can anyone offer me any insight into this issue please? Is there a better way of doing this that I've not yet found?</p> <p>Many thanks in advance for any help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload