【问题标题】:trying to get django / python to generate a urlencoded twitter web intent that shortens the url试图让 django/python 生成一个缩短 url 的 urlencoded twitter web 意图
【发布时间】:2018-09-05 03:09:13
【问题描述】:

我有一个 django 模板,它应该生成一个 twitter 网络意图共享 URL:

<a href="https://twitter.com/intent/tweet?text={{ block.value|urlencode }}%26url={{ page.get_site.root_url|urlencode }}{{ page.url|urlencode }}%26via=pathtweets

我的理解是,如果所有内容都正确编码,则 URL 应自动缩短为 t.co URL。那是对的吗?

如果是这样,我做错了什么?

在如图所示的模板中,最终文本呈现为:

https://twitter.com/intent/tweet?text=Nostrud%20voluptate%20tempor%20eu%20elit%20laborum%20do%20excepteur%20commodo%20ipsum%20veniam%20velit%20minim.%20Proident%20irure%20velit%20enim%20tempor%20labore%20voluptate%20laboris%20esse%20excepteur%20nostrud%20et.%20Fugiat%20cillum%20magna%20reprehenderit%20qui%20irure%20sint%20in%20occaecat%20officia%20cillum%20proident%20elit%20ea%20pariatur.Nostr%26url=http%3A//localhost/en/my-article-2/%26via=pathtweets

在 URL 中,推文框的内容呈现为:

Nostrud voluptate tempor eu elit laborum do excepteur commodo ipsum veniam velit minim. Proident irure velit enim tempor labore voluptate laboris esse excepteur nostrud et. Fugiat cillum magna reprehenderit qui irure sint in occaecat officia cillum proident elit ea pariatur.Nostr&url=http://localhost/en/my-article-2/&via=pathtweets

【问题讨论】:

    标签: python django twitter url-encoding webintents


    【解决方案1】:

    我想通了——动态 url http://localhost 没有作为实际 url 注册到 twitter,因为没有 .com.org 等,所以 23 个字符的 URL 计数没有生效。还意识到 URL 缩短实际上并没有在此过程的步骤中发生,它只是将任何超过 23 个字符的 URL 计为 23 个字符,以达到您的 280 限制。

    【讨论】:

      猜你喜欢
      • 2015-06-08
      • 2011-01-27
      • 1970-01-01
      • 1970-01-01
      • 2011-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-05
      相关资源
      最近更新 更多