Facebook 粉丝专页“赞”停留在 Fangate 页面而不是移动到 Wall

发布于 2024-12-17 10:46:38 字数 535 浏览 4 评论 0原文

期望的行为:使用粉丝页面顶部的“赞”按钮后,我希望将用户发送到留言墙。

当前行为:用户保留在 fangate 页面(设置为我的粉丝页面的默认登录页面的自定义选项卡)。

据我所知 这里还有一个问题,如果有人使用页面顶部的按钮,我无法控制在某人“喜欢”我的页面后触发的事件。

然而,我去过一些粉丝页面,它们确实有我想要的行为。我只是不明白他们是怎么做到的。示例:StrongMail 的 Facebook 粉丝页面

编辑:添加信息 - 我们为 Fangate 使用 iframe(以防万一)相关的)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尐偏执 2024-12-24 10:46:38

编辑:如果您想显示某些内容而不是挂在墙上,请在隐藏内容的顶部创建一个绝对定位的 div ,并在喜欢时隐藏 div

如果您使用 C# ASP.Net,我在使用此技术时从未遇到过问题。您可以检查 signed_request 并使用 JObject 进行解码,然后根据需要进行重定向。

看看这个:如何解码 OAuth 2.0 用于 C# 中的 Canvassigned_request?

您需要从此处下载并引用 JSON.Net:Json.NET

在页面加载上:

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
        }
    }

这里的解码有效负载函数:

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;
} 

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;
} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文