我有一个FB页面选项卡应用程序 - 基本上是iframe中的一个网页,当用户点击页面选项卡时会显示.
在网页内我有一个Twitter按钮.我正在使用Twitter的API来找出用户成功发布推文的时间.这是我用于此的代码:
twttr.events.bind('tweet', function(event) {
alert("tweet's ocured");
});
Run Code Online (Sandbox Code Playgroud)
问题是 - 如果我正常查看页面,我会收到alert()推文后的内容.如果我从Facebook查看它不起作用....就好像Twitter的响应没有传递到Fb上的页面?
另外在我的控制台中,我收到以下警告:
TWITTER:内容安全政策限制可能适用于您的网站.添加以抑制此警告.
.
TWITTER:请注意:应用CSP时,并非所有嵌入式时间轴和嵌入式Tweet功能都受支持.
.
Blocked a frame with origin "http://giveaway-testing.herokuapp.com" from accessing a frame with origin "http://www.facebook.com". The frame being accessed set "document.domain" to "facebook.com", but the frame requesting access did not. Both must set "document.domain" to the same value to allow access.
.
Blocked a frame with origin "http://platform.twitter.com" from accessing a frame with origin "http://www.mysitehere.com". The frame requesting access set "document.domain" to "twitter.com", but the frame being accessed did not. Both must set "document.domain" to the same value to allow access.
Has anyone dealt with these issues before? If so help is greatly appreciated!
要解决“TWITTER”控制台消息,请将以下代码添加到页面标题中:
<meta name="twitter:widgets:csp" content="on">
Run Code Online (Sandbox Code Playgroud)
Twitter 开发人员文档底部解释了元标记的使用: https: //dev.twitter.com/web/overview/widgets-meta-elements。
其他警告与 JavaScript 的同源策略有关。您原始帖子中提到的警告之一中的 http://giveaway-testing.herokuapp.com不再运行。您还有该页面的版本可供查看吗?