Is it possible to shorten url from Twitter API?

2019-06-14 21:23发布

Is there a way to get the shortened t.co url from the API? I need to shorted a url before posting tweet via API. How should I do this? Is this supported by Twitter API or do I have to use some other url shortener like bit.ly?

标签: api twitter
3条回答
The star\"
2楼-- · 2019-06-14 22:07

It isn't possible to shorten links using t.co through any means other than sending status updates or direct messages via Twitter. From the Twitter support site:

The link service at http://t.co is only used on links posted on Twitter and is not available as a general shortening service.

So, yes, you'll need to use some other shortening service.

查看更多
劫难
3楼-- · 2019-06-14 22:18

The Twitter API will pretty much shorten any link you post through it as long as it is longer than the “short_url_length” value. To answer your question, no you can't get a t.co shortened url before actually posting the tweet. But if all you need is to know the length of the t.co link, you can get the day's value of “short_url_length” (+1 for https links) from their REST API https://dev.twitter.com/rest/reference/get/help/configuration

查看更多
狗以群分
4楼-- · 2019-06-14 22:24

Looks like all URLs are now shortened with t.co

See this post on Twitter Developers

查看更多
登录 后发表回答