1

Desired Behavior: After using the Like button on top of my fan page, I want the user to be sent to the Wall.

Current Behavior: The user remains on the fangate page (custom tab that is set as the default landing page for my fan page).

From what I can tell from another question here, I can't control events that trigger after someone "Likes" my page if they use the button on top of the page.

However, I've been to some fan pages that DO have the behavior I want. I just can't figure out how they did it. Example: StrongMail's Facebook Fan Page

EDIT: Added information - We use an iframe for the Fangate (in case that's relevant)

Community
  • 1
  • 1
cfrydlewicz
  • 95
  • 1
  • 6

1 Answers1

2

EDIT: If you want to show certain content instead of going to the wall, make an absolute positioned div on top of your hidden content and hide the div when it's liked.

If you're using C# ASP.Net, I've never had an issue using this technique. You can check for the signed_request and decode using JObject and then redirect as you need.

Check this out: How to decode OAuth 2.0 for Canvas signed_request in C#?

You'll need to download and reference JSON.Net from here: Json.NET

On the page load:

if (Request.Form["signed_request"] != null)
    {
        var result = (IDictionary)DecodePayload(Request.Form["signed_request"].Split('.')[1]);

        JObject liked = JObject.Parse(result["page"].ToString());

        if (liked["liked"].ToString().Trim().ToLower() == "true")
        {
           //do redirection here
        }
    }

The decode payload function here:

public Dictionary<string, string> DecodePayload(string payload)
{
    var encoding = new UTF8Encoding();
    var decodedJson = payload.Replace("=", string.Empty).Replace('-', '+').Replace('_', '/');
    var base64JsonArray = Convert.FromBase64String(decodedJson.PadRight(decodedJson.Length + (4 - decodedJson.Length % 4) % 4, '='));
    var json = encoding.GetString(base64JsonArray);
    var jObject = JObject.Parse(json);

    var parameters = new Dictionary<string, string>();
    parameters.Add("user_id", (string)jObject["user_id"] ?? "");
    parameters.Add("oauth_token", (string)jObject["oauth_token"] ?? "");
    var expires = ((long?)jObject["expires"] ?? 0);
    parameters.Add("expires", expires > 0 ? expires.ToString() : "");
    parameters.Add("profile_id", (string)jObject["profile_id"] ?? "");
    parameters.Add("page", jObject["page"].ToString() ?? "");

    return parameters;
} 
Community
  • 1
  • 1
AdmanStrong
  • 323
  • 1
  • 8
  • This redirects the user to another tab? Or does it just redirect the iframe content? Sorry, I am not literate for C# ASP stuff, so I want to make sure this is the answer before I start digging into a new language :-P – cfrydlewicz Nov 21 '11 at 23:12
  • You'll have to use the full URL of the tab you wish to move to, just grab it from the browser when navigating to it manually. – AdmanStrong Nov 22 '11 at 14:14