Facebook iframe 选项卡应用程序对所有人可见,但该应用程序不公开?

发布于 2024-12-12 02:50:52 字数 284 浏览 0 评论 0原文

据我所知,到目前为止,可以创建您自己的 Facebook 应用程序,将自定义选项卡和 iframe 内容拖放到您的页面上。我已经完成了一些基本步骤来测试,但这是我的问题:

我正在为特定目的创建一个自定义 Facebook 登陆页面,并且我不希望该应用程序可供任何人安装。但是,在我的页面上安装该应用程序后,我希望每个人都能够看到内容。我尝试打开“沙盒”,但这隐藏了应用程序和内容。

我还没有找到可以满足我所有需求的预制 iframe 包装器。在我阅读和搜索的所有教程中,我没有看到任何人提到让他们的应用程序远离公众的担忧。

To the best of my knowledge so far, it's possible to create your own facebook app to drop a custom tab and iframed content onto your page. I've run through a few basic steps to test, but here's my problem:

I'm creating a custom facebook landing page for a specific purpose, and I don't want that app to just be available for anyone to install. However, with that app installed on my page, I want everyone to be able to see the content. I tried turning 'sandbox' on but that hides the app AND the content.

I haven't found a pre-made iframe wrapper that meets all my needs. Of all the tutorials I've read and searched for, I haven't seen anybody mention concerns with keeping their app out of the public's hands.

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

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

发布评论

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

评论(1

给不了的爱 2024-12-19 02:50:52

这很简单,解析 signed_request 并查看您的应用程序是通过页面访问还是直接通过apps.facebook.com,如果第二个为真,只需将用户重定向到您的 Facebook 页面选项卡。

function parse_signed_request($signed_request, $secret) {
  list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

  // decode the data
  $sig = base64_url_decode($encoded_sig);
  $data = json_decode(base64_url_decode($payload), true);

  if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
    error_log('Unknown algorithm. Expected HMAC-SHA256');
    return null;
  }

  // check sig
  $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
  if ($sig !== $expected_sig) {
    error_log('Bad Signed JSON signature!');
    return null;
  }

  return $data;
}

function base64_url_decode($input) {
  return base64_decode(strtr($input, '-_', '+/'));
}

$signed_request = $_POST['signed_request'];
$response = parse_signed_request($signed_request);

if(empty($response['page']['id'])){
            die('<script>top.location.href = your_page_tab_url</script>');  
}

That is easy, parse signed_request and see if you app is accessed via Page or directly via apps.facebook.com, if the second one is true, just redirect user to your Facebook Page Tab.

function parse_signed_request($signed_request, $secret) {
  list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

  // decode the data
  $sig = base64_url_decode($encoded_sig);
  $data = json_decode(base64_url_decode($payload), true);

  if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
    error_log('Unknown algorithm. Expected HMAC-SHA256');
    return null;
  }

  // check sig
  $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
  if ($sig !== $expected_sig) {
    error_log('Bad Signed JSON signature!');
    return null;
  }

  return $data;
}

function base64_url_decode($input) {
  return base64_decode(strtr($input, '-_', '+/'));
}

$signed_request = $_POST['signed_request'];
$response = parse_signed_request($signed_request);

if(empty($response['page']['id'])){
            die('<script>top.location.href = your_page_tab_url</script>');  
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文