我正在使用自定义推特按钮编写一个网站,该按钮使用 www.twitter.com/share 函数,但是我遇到的问题是在推文文本中包含哈希'#'字符。
例如:
http://www.twitter.com/share?url=www.example.com&text=I+am+eating+#branstonpickel+right+now
该推文文本显示为“,我正在吃”,并且省略了哈希表以及之后的所有内容。
我在Twitter论坛上进行了快速浏览,了解到哈希#号不能成为共享URL的一部分。在https://dev.twitter.com/discussions/512#comment-877上,有人说:
Hashes are special characters in the URL (they identify document fragments) so they, and anything following, does not get sent the server.
和
you need to URLEncode it, so use %23
当我在测试链接中尝试第二点时:
www.twitter.com/share?url=www.example.com&text=I+am+eating+%23branstonpickel+right+now
该推文文本为',我现在正在吃%23branstonpickel ',实际上包含%23而不是将其转换为哈希。
很抱歉这个棘手的问题,但是有人知道我做错了吗?
任何反馈将不胜感激:)
最佳答案
看起来这是基本设置:
https://twitter.com/intent/tweet?
url=<url to tweet>
text=<text to tweet>
hashtags=<comma separated list of hashtags, with no # on them>
这将预先构建以下消息:
<text> <url> <hashtags>
上面的例子是:
https://twitter.com/intent/tweet?url=http://www.example.com&text=I+am+eating+branston+pickel+right+now&hashtags=bransonpickel,pickles
hashtags参数曾经有个错误……它只显示前n-1个hashtag。目前,这是固定的。
关于twitter - 您如何在Twitter共享链接文本中包含主题标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9127808/