nst / STTwitter

A stable, mature and comprehensive Objective-C library for Twitter REST API 1.1
BSD 3-Clause "New" or "Revised" License
999 stars 161 forks source link

Support Twitter's New Character Counting Method #264

Closed inb4ohnoes closed 8 years ago

inb4ohnoes commented 8 years ago

Would be awesome if STTwitter supported these new changes! https://dev.twitter.com/overview/api/upcoming-changes-to-tweets

nst commented 8 years ago

I added support for extended tweets (creation and consumption) in https://github.com/nst/STTwitter/commit/c5443851a3500b4547eb4be15089a6c49fac4587. Can you please ensure that it works as you expect?

inb4ohnoes commented 8 years ago

Everything seems works as expected on the API part, thank you so much! Can you also update st_numberOfCharactersInATweet to reflect new counting?

nst commented 8 years ago

Extended tweets are made of 3 parts:

  1. mentions prefix (optional)
  2. text region
  3. attachment URL (optional)

Even though the total overall displayable text length may exceed 140 characters (part 1 + part 2 + part 3), the "text region" (part 2) remains limited to 140 characters, which can be counted with st_numberOfCharactersInATweet.

inb4ohnoes commented 8 years ago

Yeah, I was hoping st_numberOfCharactersInATweet would be able to handle counting (or not counting) the cases at the beginning and end as well, but if you believe it shouldn't be part of the scope of that method that's ok.

inb4ohnoes commented 8 years ago

Also, I didn't notice this before, but doesn't Twitter say that the extended tweet mode parameter should apply across all rest endpoints? I noticed you only added that parameter for some methods.

inb4ohnoes commented 8 years ago

There's also a spelling mistake. You wrote "extented" instead of "extended" for the method definition. I'll create a PR later that fixes these issues.

nst commented 8 years ago

Doesn't Twitter say that the extended tweet mode parameter should apply across all rest endpoints?

Not all.

"Any endpoints that return Tweets will accept a new tweet_mode request parameter."

https://dev.twitter.com/overview/api/upcoming-changes-to-tweets

There's also a spelling mistake. You wrote "extented" instead of "extended" for the method definition.

Sorry for that thank you for spotting the typo.

inb4ohnoes commented 8 years ago

Ah sorry, I was looking at the chart they provide which says "any endpoint". In any case, I've created the PR https://github.com/nst/STTwitter/pull/266. I've verified that all the changes I've made work. Please take a gander!

nst commented 8 years ago

So, could you please update https://github.com/nst/STTwitter/pull/266 so that it does add the "useExtendedTweetMode" parameter only to methods that return Tweets?

inb4ohnoes commented 8 years ago

Ok, I'll do that now. Should convenience methods have extended tweets turned on by default?

nst commented 8 years ago

Twitter API default is compatibility mode "to support older clients and display methods". This will change "in the future".

Also, users of STTwitter convenience methods don't expect the response format to suddenly change.

So, I would keep the compatibility mode by default for now.

inb4ohnoes commented 8 years ago

Ok, I've updated https://github.com/nst/STTwitter/pull/266. Can you check?

nst commented 8 years ago

merged