gpt4 book ai didi

javascript - Twitter 网络意图 URL 缩短器

转载 作者:行者123 更新时间:2023-11-28 07:27:54 24 4
gpt4 key购买 nike

我正在尝试使用 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 ,它说:

A fully-qualified URL with a HTTP or HTTPS scheme, URL-encoded. The provided URL will be shortened with Twitter’s t.co to the number of characters specified by short_url_length.

Example Value: http:%3A%2F%2Fexample.com%2F

我在新窗口的控制台中查看了此错误

Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-inline' 'nonce-PfLsh9SlUoh7UKtdZ7mgcA==' 'unsafe-eval' https:". Note that 'unsafe-inline' is ignored if either a hash or nonce value is present in the source list.

我需要采取其他步骤才能使网址缩短程序发挥作用吗?

最佳答案

我发现了我遇到的问题。我正在开发一个 IP 地址的开发链接。 Twitter 的 URL 缩短器显然不喜欢这样。当我在常规 URL 上测试它时,URL 缩短了。

关于javascript - Twitter 网络意图 URL 缩短器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29435880/

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