来自 Twitter 源的长 URL,无需进行额外的 API 调用/HTTP 请求

发布于 2024-12-11 13:45:01 字数 813 浏览 0 评论 0原文

是否有任何内置方法可以从 Twitter RSS 提要中获取长的、扩展的 URL?现在,提要将所有网址列为 http://t.co...。我想做 Twitter 显示的功能并显示长 URL;我还希望避免对 feed 中的每个 URL 执行 API 调用或 HTTP 请求。理想情况下,我还想避免直接使用 Twitter API,但如果这是唯一的方法,那就这样吧。

澄清

我不想对每个 t.co 链接执行单独的请求,或调用 Twitter API。我希望我可以发出一个单个请求,将长 URL 包含在元数据中(甚至提供 Twitter 上显示的完整扩展形式的推文) 。事实证明,实现此目的的方法是从 search.twitter.com 请求 JSON 版本而不是 RSS feed,并附加 include_entities=True

重写,希望这能让我更清楚地

使用 http://search.twitter.com/search.rss 获取与搜索词匹配的推文提要。该提要仅包含缩短的 t.co 网址。有没有办法修改我的请求,以便推文包含扩展的 URL?

目标是一个请求,而不是必须浏览推文并单独解析每个 t.co 网址(特别是对于包含数十个 t.co 的提要) url,这意味着几十个单独的请求)。如果有必要,我愿意直接使用 Twitter API 来进行搜索,而不是使用 RSS,但就我的目的而言,使用 feed 更为理想。

Is there any built-in way to get the long, expanded URL from a twitter RSS feed? Right now the feed lists all the urls as http://t.co.... I'd like to do what the Twitter display does and display the long URLs; I'd also like to avoid having to do either an API call or HTTP request for each URL in the feed. Ideally, I'd also like to avoid using the Twitter API directly but if that's the only way, so be it.

Clarification

I'm not interested in doing a separate request for every single t.co link, or calling the Twitter API. I was hoping there was a single request I could make that would include the long URLs in the metadata (or even provide the tweet in full expanded form as it appears on Twitter). Turns out the way to do this is by requesting the JSON version from search.twitter.com rather than the RSS feed, and tacking on include_entities=True.

Rewrite, hopefully this makes it more clear

I'm using http://search.twitter.com/search.rss to get a feed of tweets matching a search term. The feed contains only the shortened t.co urls. Is there a way to modify my request so that the tweets contain the expanded URLs instead?

The goal is to do just one request rather than having to go through the tweets and parse each t.co url separately (especially since for a feed with several dozen t.co urls, that means several dozen separate requests). If necessary, I am willing to use the Twitter API directly to do the search instead of using RSS, but for my purposes using a feed is more ideal.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忘东忘西忘不掉你 2024-12-18 13:45:01

不,Twitter 在其 RSS 响应中不提供 urls 实体,include_entities 选项似乎也不起作用。您必须使用不同的响应格式,例如 JSON(您可以使用 include_entities 选项,其中包含一个 entities['urls'][n]['expanded_url'] 对象),或者在事后自行“取消缩短”URL。

No, Twitter does not offer a urls entity in its RSS responses, nor does the include_entities option appear to work. You'll have to use a different response format e.g. JSON (with which you can use the include_entities option which includes an entities['urls'][n]['expanded_url'] object), or "unshorten" the URLs yourself after the fact.

黯淡〆 2024-12-18 13:45:01

有一种方法可以在不直接使用 Twitter API 的情况下完成此操作。您可以使用多种资源之一,

http://expandurl.appspot.com/

API 调用原型:http://expandurl.appspot.com/expand?url=

http://longurl.org

API调用原型: http://api.longurl.org/v2/expand?url=

http://unshort.me /

API 调用原型:http://api.unshort.me/?r=http://

当然,您也可以直接使用 Twitter API,正如 Jordan 提到的,包括&include_entities=1true 作为某些调用的参数。

还可以尝试对 URL 进行 CURL 操作,看看可以从中获取哪些信息。我认为这几乎用尽了所有的选择。

There is a way to do this without using the Twitter API directly. You can use one of several resources,

http://expandurl.appspot.com/

API call prototype : http://expandurl.appspot.com/expand?url=

http://longurl.org

API call prototype : http://api.longurl.org/v2/expand?url=

http://unshort.me/

API call prototype: http://api.unshort.me/?r=http://

of course you can also use the Twitter API directly for this as Jordan mentioned by including &include_entities=1 or true as a parameter to some calls.

also try to CURL the URL and see what information you can gleam from that. I think this pretty much exhausts the options.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文