简体   繁体   English

如何强制Facebook在标签网址中使用https

[英]How to force Facebook to use https into a tab url

My server use only https with an htaccess redirect at root level, when my tab app is called from a FB page if the user use an http connection I lost the signed request. 如果从FB页面调用我的Tab应用程序(如果用户使用http连接,则我丢失了签名的请求),则服务器仅在根级别使用htaccess重定向的https。 Everyone knows a solution? 每个人都知道解决方案吗? How to force Facebook to use https when call a tab? 如何在调用标签页时强制Facebook使用https? thanks luc 谢谢卢克

How to force Facebook to use https when call a tab? 如何在调用标签页时强制Facebook使用https?

In theory, HTTP status codes 307 (Temporary Redirect) and 308 (Permanent Redirect) should be used for this, since they require the method to stay the same, so the client would have to fetch the resource that's been redirected to using POST with the same data again. 理论上,应该为此使用HTTP状态代码307(临时重定向)和308(永久重定向),因为它们要求方法保持不变,因此客户端将必须获取已重定向到通过POST与POST一起使用的资源。同样的数据。

However, I have no experience how well this works with the browsers that are out there. 但是,我没有经验,无法与现有的浏览器一起使用。

Probably better to “redirect” client-side, using JavaScript. 使用JavaScript“重定向”客户端可能更好。 Of course, that requires a resource that is available using HTTP only, and is not redirected server-side to it's HTTPS counterpart. 当然,这需要仅通过HTTP可用的资源,并且该资源不会在服务器端重定向到它的HTTPS副本。


In the future, this “problem” will go away on it's own, I assume – since Facebook announced end of last year that they will move all users to HTTPS; 我认为,将来,这个“问题”将自行解决-自从Facebook于去年年底宣布,他们将把所有用户转移到HTTPS以来; so I think some time from now we won't be required to give a HTTP URL for canvas/page tab apps any more, and use just one HTTPS version. 因此,我认为从现在开始的某个时候,我们将不再需要为canvas / page选项卡应用程序提供HTTP URL,而仅使用一个HTTPS版本。

I resolved in this way: 我以这种方式解决:

In the FBapp manager I used as http url a page created on a different server that accept http. 在FBapp管理器中,我将http url用作在其他接受HTTP的服务器上创建的页面。 In this page I used the following code . 在此页面中,我使用了以下代码。

 $signed_request = $facebook->getSignedRequest();
 $page_id   = $signed_request["page"]["id"];
 $fql_query_url = "https://graph.facebook.com"
    ."/$page_id?fields=link"
."";
try {
    $fql_query_result = @file_get_contents($fql_query_url);
    $fql_query_obj = json_decode($fql_query_result, true);
} catch(Exception $o){   }
 $pageinfo = $fql_query_obj[link];
 $pageinfo = str_replace("http://","https://",$pageinfo);
 $tabpage = "$pageinfo"."?sk=app_$appId";
 echo "
 <!-- force tab iframe -->
 <script type=\"text/javascript\">
  top.location.replace('$tabpage');
 </script>
";
 ?>

that's all 就这样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM