-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support the new extended tweet_mode
API
#200
Conversation
Will fix the detected issues in tests. |
There we go, I've fixed one bug and updated the test cases to match the new API responses / requests. |
This can probably still be improved by attaching our own UnmarshalJSON method to anaconda.Tweet. Will look at that now. |
Got a fix for retweets coming up and will squash everything then. |
3343ec3
to
cdb7a95
Compare
Alright, I think we're all set! |
cdb7a95
to
9660d51
Compare
extended tweet_mode
APIextended tweet_mode
API
Looks like Travis-CI is stuck... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after a rebase!
{"created_at":"Tue Feb 19 08:04:41 +0000 2013","id":303777106620452864,"id_str":"303777106620452864","full_text":"golang-syd is in session. Dave Symonds is now talking about API design and protobufs. #golang http:\/\/t.co\/eSq3ROwu","truncated":false,"entities":{"hashtags":[{"text":"golang","indices":[86,93]}],"symbols":[],"user_mentions":[],"urls":[],"media":[{"id":303777106628841472,"id_str":"303777106628841472","indices":[94,114],"media_url":"http:\/\/pbs.twimg.com\/media\/BDc7q0OCEAAoe2C.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/BDc7q0OCEAAoe2C.jpg","url":"http:\/\/t.co\/eSq3ROwu","display_url":"pic.twitter.com\/eSq3ROwu","expanded_url":"http:\/\/twitter.com\/go_nuts\/status\/303777106620452864\/photo\/1","type":"photo","sizes":{"small":{"w":340,"h":255,"resize":"fit"},"medium":{"w":600,"h":450,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"large":{"w":1024,"h":768,"resize":"fit"}}}]},"extended_entities":{"media":[{"id":303777106628841472,"id_str":"303777106628841472","indices":[94,114],"media_url":"http:\/\/pbs.twimg.com\/media\/BDc7q0OCEAAoe2C.jpg","media_url_https":"https:\/\/pbs.twimg.com\/media\/BDc7q0OCEAAoe2C.jpg","url":"http:\/\/t.co\/eSq3ROwu","display_url":"pic.twitter.com\/eSq3ROwu","expanded_url":"http:\/\/twitter.com\/go_nuts\/status\/303777106620452864\/photo\/1","type":"photo","sizes":{"small":{"w":340,"h":255,"resize":"fit"},"medium":{"w":600,"h":450,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"large":{"w":1024,"h":768,"resize":"fit"}}}]},"source":"\u003ca href=\"http:\/\/twitter.com\/download\/android\" rel=\"nofollow\"\u003eTwitter for Android\u003c\/a\u003e","in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":113419064,"id_str":"113419064","name":"Go","screen_name":"golang","location":"","description":"Go will make you love programming again. I promise.","url":"http:\/\/t.co\/C4svVTkUmj","entities":{"url":{"urls":[{"url":"http:\/\/t.co\/C4svVTkUmj","expanded_url":"http:\/\/golang.org\/","display_url":"golang.org","indices":[0,22]}]},"description":{"urls":[]}},"protected":false,"followers_count":42195,"friends_count":0,"listed_count":1115,"created_at":"Thu Feb 11 18:04:38 +0000 2010","favourites_count":211,"utc_offset":-28800,"time_zone":"Alaska","geo_enabled":false,"verified":false,"statuses_count":1954,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"C0DEED","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/2388595262\/v02jhlxou71qagr6mwet_normal.png","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images\/2388595262\/v02jhlxou71qagr6mwet_normal.png","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_banners\/113419064\/1398369112","profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"has_extended_profile":false,"default_profile":true,"default_profile_image":false,"following":true,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":2,"favorite_count":3,"favorited":false,"retweeted":false,"possibly_sensitive":false,"possibly_sensitive_appealable":false,"lang":"en"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is tough to diff visually - mind pointing me to the the difference here? Is the only difference text
->full_text
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed the only difference (s/,"text":/,"full_text":
). I'm currently writing a little script to regenerate those JSON files for us, so we can update our mocks whenever Twitter updates their API.
@@ -197,7 +199,7 @@ func Test_GetTweet(t *testing.T) { | |||
} | |||
|
|||
if tweet.Text != tweetText { | |||
t.Fatalf("Tweet %d contained incorrect text. Received: %s", tweetId, tweetText) | |||
t.Fatalf("Tweet %d contained incorrect text. Received: %s", tweetId, tweet.Text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hah - good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one gave me headaches trying to debug my changes. Until I finally noticed this mistake was misleading me the entire time ;-)
Twitter's API has changed and now shortens statuses that are longer than 140 chars, but have an acceptable length by the new Twitter rules. This change introduces Tweet.FullText, which contains the unshortened form of the status. Tweet.Text's behavior should be unchanged and will contain the shortened form. All API requests are now executed in the new extended mode. Sadly the streaming API now behaves slightly different to the regular REST API and contains the extended Tweet information in a separate struct. This change also parses this extra struct and correctly merges the status into the Tweet struct, so both API modes behave the same and remain backwards compatible, as far as anaconda users are concerned. This PR makes ChimeraCoder#158 and ChimeraCoder#190 obsolete.
9660d51
to
4dba959
Compare
Rebased to upstream/master! |
Twitter's API has changed and now shortens statuses that are longer
than 140 chars, but have an acceptable length by the new Twitter
rules.
This change introduces Tweet.FullText, which contains the
unshortened form of the status. Tweet.Text's behavior should be
unchanged and will contain the shortened form. All API requests are
now executed in the new extended mode.
Sadly the streaming API now behaves slightly different to the regular
REST API and contains the extended Tweet information in a separate
struct. This change also parses this extra struct and correctly merges
the status into the Tweet struct, so both API modes behave the same
and remain backwards compatible, as far as anaconda users are concerned.
This PR makes #158 and #190 obsolete.