Facebook 画布 URL 重定向到 https

发布于 2025-01-03 21:05:35 字数 517 浏览 1 评论 0原文

我有一个 Facebook 应用程序,同时包含画布 url 和安全画布 url。

当我的用户在页面选项卡中打开应用程序时,我的应用程序会读取带有 page idsigned_request 并为此特定 FB 页面提供内容。

当我的用户在 FB 中使用 https 冲浪注销并且下一个用户仅使用 http 冲浪登录时,我的应用程序会重定向到安全画布 URL,并且我的 < code>signed_request 参数丢失。如果没有 signed_request 参数,我无法确定我的应用应提供哪个页面。

当我清空浏览器缓存时,将使用我的应用程序的正确 http URL。

有没有办法始终在 FB 应用程序中使用 https,或者阻止浏览器缓存 https URL?

谢谢!

I have a Facebook app with both, canvas url and secure canvas url.

When my user opens the app within a page tab, my app reads the signed_request with the page id and delivers content for this specific FB page.

When my user uses https surfing in FB logs out and the next user logs in with only http surfing, my app gets redirected to the secure canvas url and my signed_request parameter is lost. Without the signed_request parameter I can't determine which page should be served by my app.

When I empty the browser cache, the right http URL of my app is used.

Is there a way to always use https with FB apps, or prevent the browser from caching the https URL?

Thanks!

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

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

发布评论

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

评论(1

这个俗人 2025-01-10 21:05:35

如果您想从 http 重定向到 https 并且不丢失signed_request POST 参数,您可以在重定向之前手动捕​​获它并将其作为 GET 参数附加到 URL。见下文!

// Force SSL
if(443 != $_SERVER['SERVER_PORT'] || 'on' != $_SERVER['HTTPS'])
{
    $queryString = $_SERVER['QUERY_STRING'];
    $hadQueryString = '' == $queryString ? false : true;
    $baseUrl = $_SERVER['REQUEST_URI'];
    $questionMark = strpos($_SERVER['REQUEST_URI'], '?');

    if(false !== $questionMark)
    {
        $baseUrl = substr($_SERVER['REQUEST_URI'], 0, $questionMark);
    }

    if($hadQueryString && isset($_REQUEST['signed_request']))
    {
        $queryString = $_SERVER['QUERY_STRING'] . '&signed_request=' . $_REQUEST['signed_request'];
    }
    elseif(isset($_REQUEST['signed_request']))
    {
        $queryString = 'signed_request=' . $_REQUEST['signed_request'];
    }

    $newLocation = 'https://' . $_SERVER['HTTP_HOST'] . $baseUrl . '?' . $queryString;

    header('HTTP/1.1 301 Moved Permanently');
    header('Location: ' . $newLocation);
    exit();
}

If you want to redirect from http to https and not lose the signed_request POST parameter, you can manually snag it before the redirect and append it to the URL as a GET parameter. See below!

// Force SSL
if(443 != $_SERVER['SERVER_PORT'] || 'on' != $_SERVER['HTTPS'])
{
    $queryString = $_SERVER['QUERY_STRING'];
    $hadQueryString = '' == $queryString ? false : true;
    $baseUrl = $_SERVER['REQUEST_URI'];
    $questionMark = strpos($_SERVER['REQUEST_URI'], '?');

    if(false !== $questionMark)
    {
        $baseUrl = substr($_SERVER['REQUEST_URI'], 0, $questionMark);
    }

    if($hadQueryString && isset($_REQUEST['signed_request']))
    {
        $queryString = $_SERVER['QUERY_STRING'] . '&signed_request=' . $_REQUEST['signed_request'];
    }
    elseif(isset($_REQUEST['signed_request']))
    {
        $queryString = 'signed_request=' . $_REQUEST['signed_request'];
    }

    $newLocation = 'https://' . $_SERVER['HTTP_HOST'] . $baseUrl . '?' . $queryString;

    header('HTTP/1.1 301 Moved Permanently');
    header('Location: ' . $newLocation);
    exit();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文