【发布时间】:2015-06-08 18:16:36
【问题描述】:
我正在尝试使用 Twitter Web Intents 向我的页面添加自定义推文功能。这是一个包含大量查询参数的复杂页面,超过 140 个字符。 URL 没有缩短。
这是我正在使用的功能:
function tweet(image){
var pageURL = createPreloadURL(image)
var width = 575,
height = 400,
left = ($(window).width() - width) / 2,
top = ($(window).height() - height) / 2,
url = 'https://twitter.com/intent/tweet?url='+ encodeURIComponent(pageURL),
opts = 'status=1' +
',width=' + width +
',height=' + height +
',top=' + top +
',left=' + left;
window.open(url, 'twitter', opts);
}
我安慰了 URL 字符串,它似乎是正确的格式:
http%3A%2F%2Fexample.com%2Fpreload.cfm%3Fproduct_id%3D4420%26year%3D2014%26make_id%3D58%26model_id%3D21604%26diameter%3D17....
在文档 here 上,它说:
具有 HTTP 或 HTTPS 方案的完全限定 URL,URL 编码。这 提供的 URL 将使用 Twitter 的 t.co 缩短为 short_url_length 指定的字符。
示例值:http:%3A%2F%2Fexample.com%2F
我在新窗口中查看控制台时遇到此错误
拒绝执行内联脚本,因为它违反了以下内容 内容安全策略指令:“script-src 'unsafe-inline' 'nonce-PfLsh9SlUoh7UKtdZ7mgcA==' 'unsafe-eval' https:"。请注意 如果存在哈希值或 nonce 值,则忽略“unsafe-inline” 在源列表中。
是否需要采取其他步骤才能使网址缩短器正常工作?
【问题讨论】:
标签: javascript twitter