gpt4 book ai didi

facebook - channel 文件和CDN

转载 作者:行者123 更新时间:2023-12-01 07:46:15 25 4
gpt4 key购买 nike

我的主要 javascript(以及所有静态内容)包含在 https://static.anuary.com 中。用户正在浏览的 URL 是 https://dev.anuary.com/somepath/

channel 文件需要在哪里,dev.anuary.comstatic.anuary.com?目前是 http://static.anuary.com/channel.html


我问是因为我仍然收到错误消息:

Unsafe JavaScript attempt to access frame with URL https://www.facebook.com/dialog/oauth?access_token=[..]&api_key=[..]&app_id=[..]&client_id=[..]&display=popup&domain=dev.anuary.com&locale=en_US&origin=1&redirect_uri=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D6%23cb%3Df3ac7a0544%26origin%3Dhttp%253A%252F%252Fdev.anuary.com%252Ff373e908a8%26domain%3Ddev.anuary.com%26relation%3Dopener%26frame%3Df312def42c&response_type=token%2Csigned_request&scope=email%2Cuser_birthday%2Cuser_likes%2Cuser_interests%2Cpublish_stream&sdk=joey from frame with URL http://dev.anuary.com/658fe23c24564ac978c31d167549c4ce8b36686d65a78ad99bfb38765d46e232/. Domains, protocols and ports must match.


回应@dtbarne:

好吧,就是这样——我还是不知道,因为我已经尝试了 bowth 方法,以防它产生相同的错误:

Unsafe JavaScript attempt to access frame with URL https://www.facebook.com/dialog/oauth?access_token=[..]&api_key=[..]&app_id=[..]&client_id=[..]&display=popup&domain=dev.anuary.com&locale=en_US&origin=1&redirect_uri=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D6%23cb%3Df1ee31b93%26origin%3Dhttp%253A%252F%252Fdev.anuary.com%252Ff9359b2f%26domain%3Ddev.anuary.com%26relation%3Dopener%26frame%3Df18e94f9c4&response_type=token%2Csigned_request&scope=email%2Cuser_birthday%2Cuser_likes%2Cuser_interests%2Cpublish_stream&sdk=joey from frame with URL http://dev.anuary.com/658fe23c24564ac978c31d167549c4ce8b36686d65a78ad99bfb38765d46e232/. Domains, protocols and ports must match.

最佳答案

正如您自己所说,这个错误不是 fatal error ,而是警告用户可能发生了可疑的事情。

Facebook 还在其错误系统中将此问题标记为 By Design:Bugs > Unsafe JavaScript attempt to access frame with URL... .
此外,这里有很多关于堆栈溢出的线程,例如:Facebook Authentication - Unsafe JavaScript attempt to access frame with URL .

现在我们知道这个“错误消息”是不可避免的,只要一切对您有用,请按您的意愿使用该 channel 。
正如文档中所述,您甚至不需要使用该 channel :

The channelUrl parameter is optional, but recommended. Providing a channel file can help address three specific known issues. First, pages that include code to communicate across frames may cause Social Plugins to show up as blank without a channelUrl. Second, if no channelUrl is provided and a page includes auto-playing audio or video, the user may hear two streams of audio because the page has been loaded a second time in the background for cross domain communication. Third, a channel file will prevent inclusion of extra hits in your server-side logs. If you do not specify a channelUrl, you can remove page views containing fb_xd_bust or fb_xd_fragment parameters from your logs to ensure proper counts.

但它还指出:

The channel file addresses some issues with cross domain communication in certain browsers.

所以由你来决定。
我个人建议使用 channel 并从常规服务器而不是静态服务器提供文件。
但是,您应该将输出设置为具有较长的缓存到期日期,这样您的服务器就不会收到对此文件的大量请求,正如他们在 JS SDK documentation page 中提到的那样。 :

<?php
$cache_expire = 60*60*24*365;
header("Pragma: public");
header("Cache-Control: max-age=".$cache_expire);
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$cache_expire) . ' GMT');
?>
<script src="//connect.facebook.net/en_US/all.js"></script>

(php 示例,但可以用任何语言完成)。

希望这个答案能为您澄清一些事情。

关于facebook - channel 文件和CDN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10629875/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com