assafgi / python-twitter

Automatically exported from code.google.com/p/python-twitter
Apache License 2.0
0 stars 0 forks source link

PostUpdate() does not take link-shortening into account - patch included #214

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. call api.PostUpdate() with a status longer than 140 characters that include 
a link longer than 19 characters, fe:
'General overview on how to make your website work on different screen sizes at 
http://www.uxbooth.com/blog/how-to-design-a-mobile-responsive-website/'

What is the expected output?
An new post on Twitter 

What do you see instead?
"Text must be less than or equal to 140 characters. "

What version of the product are you using? On what operating system?
dev-python/python-twitter, 0.8.1, Linux (Gentoo)

Please provide any additional information below.
Twitter shortens all links, even when using the API. According to their 
documentation at https://support.twitter.com/articles/78124 all links will be 
19 chars long when posted.

Patch only modifies PostUpdate(), the PostUpdates() and/or other methods might 
need the same treatment.

Original issue reported on code.google.com by ceesjan....@gmail.com on 29 Oct 2011 at 1:36

Attachments:

GoogleCodeExporter commented 9 years ago
Note that 19 is the current length of shortened links, but it might get longer 
in time. 
See https://dev.twitter.com/docs/tco-link-wrapper/faq :
"Will t.co-wrapped links always be the same length?

The maximum length of t.co URLs will change over time. Issue a request daily to 
GET help/configuration and examine the fields short_url_length and 
short_url_length_https to determine the current maximum length of wrapped URLs. 
We do not expect these values to change often.

It's important to note that you won't necessarily know the length of a t.co URL 
before posting. Consider the short_url_length field a maximum possible length 
for a t.co-wrapped link. When designing a tweet entry box, it's best to 
consider all URLs as equalling the maximum possible short_url_length.
"

Original comment by lio...@gmail.com on 3 Nov 2011 at 2:08

GoogleCodeExporter commented 9 years ago
committed changeset 239:7fbd0f820d7d

while I didn't adjust the patch to retrieve the short length from Twitter as 
liorus suggests above, I did make it calculate the text based on a value that 
Api stores that defaults to 19

Api._shortlink_size

Original comment by bear42 on 3 Dec 2011 at 10:40