How to post links with the twitter API?

2019-08-05 09:53发布

问题:

I'm using the twitter API, but when I post links they are showing up as text and not links. I haven't been able to find the documentation showing how to post a link that actually works.

回答1:

If you don't keep the prefix (http://) and just post something like www.google.com, the link won't be picked up.



回答2:

If the URL contains special characters you need encode it before posting to Twitter so it will be converted to a link:

from urllib import quote
url = quote(url)


标签: api rest twitter