Skip to content
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

Handle quoted tweets #4

Closed
blessenm opened this issue Nov 10, 2015 · 1 comment

Comments

Projects
None yet
1 participant
@blessenm
Copy link
Owner

commented Nov 10, 2015

Handle quoted tweets if found. Sample data below.

https://twitter.com/sindresorhus/status/664112304540155905

{"created_at":"Tue Nov 10 16:08:06 +0000 2015","id":664112304540155905,"id_str":"664112304540155905","text":"For once I was right. https://t.co/CQAqQClGKN","source":"\u003ca href="http://twitter.com" rel="nofollow"\u003eTwitter Web Client\u003c/a\u003e","truncated":false,"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":170686450,"id_str":"170686450","name":"Sindre Sorhus","screen_name":"sindresorhus","location":"\u2708","description":"Aspiring rebel. \u2665\ufe0f Node.js .\u2022\u25cb\u00b0\u2605\u263e Creator of AVA, TodoMVC, @yeoman. Blog: https://t.co/v33jOTfXIi","url":"https://t.co/Po2lqJEFOu","entities":{"url":{"urls":[{"url":"https://t.co/Po2lqJEFOu","expanded_url":"https://sindresorhus.com","display_url":"sindresorhus.com","indices":[0,23]}]},"description":{"urls":[{"url":"https://t.co/v33jOTfXIi","expanded_url":"https://blog.sindresorhus.com","display_url":"blog.sindresorhus.com","indices":[74,97]}]}},"protected":false,"followers_count":19476,"friends_count":164,"listed_count":714,"created_at":"Sun Jul 25 13:48:23 +0000 2010","favourites_count":8237,"utc_offset":3600,"time_zone":"Stockholm","geo_enabled":true,"verified":false,"statuses_count":9174,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"FAFAFA","profile_background_image_url":"http://pbs.twimg.com/profile_background_images/378800000162762149/nc8yEsGJ.jpeg","profile_background_image_url_https":"https://pbs.twimg.com/profile_background_images/378800000162762149/nc8yEsGJ.jpeg","profile_background_tile":false,"profile_image_url":"http://pbs.twimg.com/profile_images/630442696608354304/v_NKeZ5W_normal.png","profile_image_url_https":"https://pbs.twimg.com/profile_images/630442696608354304/v_NKeZ5W_normal.png","profile_banner_url":"https://pbs.twimg.com/profile_banners/170686450/1439144356","profile_link_color":"27276A","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":false,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":true,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"quoted_status_id":69389011847884800,"quoted_status_id_str":"69389011847884800","quoted_status":{"created_at":"Sat May 14 13:10:04 +0000 2011","id":69389011847884800,"id_str":"69389011847884800","text":"#nodejs and #python is soo awesome, I'm never touching #PHP again.","source":"\u003ca href="http://twitter.com/#!/download/ipad" rel="nofollow"\u003eTwitter for iPad\u003c/a\u003e","truncated":false,"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":170686450,"id_str":"170686450","name":"Sindre Sorhus","screen_name":"sindresorhus","location":"\u2708","description":"Aspiring rebel. \u2665\ufe0f Node.js .\u2022\u25cb\u00b0\u2605\u263e Creator of AVA, TodoMVC, @yeoman. Blog: https://t.co/v33jOTfXIi","url":"https://t.co/Po2lqJEFOu","entities":{"url":{"urls":[{"url":"https://t.co/Po2lqJEFOu","expanded_url":"https://sindresorhus.com","display_url":"sindresorhus.com","indices":[0,23]}]},"description":{"urls":[{"url":"https://t.co/v33jOTfXIi","expanded_url":"https://blog.sindresorhus.com","display_url":"blog.sindresorhus.com","indices":[74,97]}]}},"protected":false,"followers_count":19476,"friends_count":164,"listed_count":714,"created_at":"Sun Jul 25 13:48:23 +0000 2010","favourites_count":8237,"utc_offset":3600,"time_zone":"Stockholm","geo_enabled":true,"verified":false,"statuses_count":9174,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"FAFAFA","profile_background_image_url":"http://pbs.twimg.com/profile_background_images/378800000162762149/nc8yEsGJ.jpeg","profile_background_image_url_https":"https://pbs.twimg.com/profile_background_images/378800000162762149/nc8yEsGJ.jpeg","profile_background_tile":false,"profile_image_url":"http://pbs.twimg.com/profile_images/630442696608354304/v_NKeZ5W_normal.png","profile_image_url_https":"https://pbs.twimg.com/profile_images/630442696608354304/v_NKeZ5W_normal.png","profile_banner_url":"https://pbs.twimg.com/profile_banners/170686450/1439144356","profile_link_color":"27276A","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":false,"has_extended_profile":false,"default_profile":false,"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":13,"entities":{"hashtags":[{"text":"nodejs","indices":[0,7]},{"text":"python","indices":[12,19]},{"text":"PHP","indices":[55,59]}],"symbols":[],"user_mentions":[],"urls":[]},"favorited":false,"retweeted":false,"lang":"en"},"is_quote_status":true,"retweet_count":2,"favorite_count":18,"entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[{"url":"https://t.co/CQAqQClGKN","expanded_url":"https://twitter.com/sindresorhus/status/69389011847884800","display_url":"twitter.com/sindresorhus/s\u2026","indices":[22,45]}]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"possibly_sensitive_appealable":false,"lang":"en"}

@blessenm

This comment has been minimized.

Copy link
Owner Author

commented Nov 11, 2015

There is no clear indication that I know of that says a url in the entity object is an embedded tweet. My current idea is to check for the presence of quoted_status and if the url item is the last item in the urls array in entities object.

Below is a tweet object with a url and a quoted tweet.

{"created_at":"Wed Nov 11 15:38:07 +0000 2015","id":664467145217191936,"id_str":"664467145217191936","text":"Web of Things at W3C #wot https://t.co/9WEhqqzPEr https://t.co/OZyeQiLitx","source":"\u003ca href="http://twitter.com/download/iphone" rel="nofollow"\u003eTwitter for iPhone\u003c/a\u003e","truncated":false,"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":35761106,"id_str":"35761106","name":"W3C","screen_name":"w3c","location":"MIT | ERCIM | Keio | Beihang","description":"The World Wide Web Consortium (W3C) develops interoperable technologies (specifications, guidelines, software, and tools) to lead the Web to its full potential.","url":"http://t.co/Sw18LxrLQo","entities":{"url":{"urls":[{"url":"http://t.co/Sw18LxrLQo","expanded_url":"http://www.w3.org/","display_url":"w3.org","indices":[0,22]}]},"description":{"urls":[]}},"protected":false,"followers_count":148954,"friends_count":154,"listed_count":5850,"created_at":"Mon Apr 27 14:56:11 +0000 2009","favourites_count":1035,"utc_offset":3600,"time_zone":"Paris","geo_enabled":true,"verified":true,"statuses_count":7022,"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/539699509899452416/fBxukr4n_normal.png","profile_image_url_https":"https://pbs.twimg.com/profile_images/539699509899452416/fBxukr4n_normal.png","profile_banner_url":"https://pbs.twimg.com/profile_banners/35761106/1399332736","profile_link_color":"0084B4","profile_sidebar_border_color":"DFDFDF","profile_sidebar_fill_color":"F3F3F3","profile_text_color":"333333","profile_use_background_image":false,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":true,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"quoted_status_id":664137304739565568,"quoted_status_id_str":"664137304739565568","quoted_status":{"created_at":"Tue Nov 10 17:47:27 +0000 2015","id":664137304739565568,"id_str":"664137304739565568","text":"Vint Cerf foresees "chaotic evolution" of the Internet of Things in the next decade, due to lack of standards. @vgcerf #IGF2015","source":"\u003ca href="http://twitter.com" rel="nofollow"\u003eTwitter Web Client\u003c/a\u003e","truncated":false,"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":14348732,"id_str":"14348732","name":"Rafael Prince","screen_name":"rafaelprince","location":"Bras\u00edlia / London","description":"Brazilian diplomat, Digital International Studies PhD student @KingsCollegeLon don, @KingsDH. Internet Governance, e-diplomacy and all things digital.","url":null,"entities":{"description":{"urls":[]}},"protected":false,"followers_count":990,"friends_count":1721,"listed_count":85,"created_at":"Thu Apr 10 05:21:52 +0000 2008","favourites_count":7269,"utc_offset":null,"time_zone":null,"geo_enabled":true,"verified":false,"statuses_count":17350,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"000000","profile_background_image_url":"http://abs.twimg.com/images/themes/theme18/bg.gif","profile_background_image_url_https":"https://abs.twimg.com/images/themes/theme18/bg.gif","profile_background_tile":false,"profile_image_url":"http://pbs.twimg.com/profile_images/614550603210059777/iZj6jhuW_normal.jpg","profile_image_url_https":"https://pbs.twimg.com/profile_images/614550603210059777/iZj6jhuW_normal.jpg","profile_banner_url":"https://pbs.twimg.com/profile_banners/14348732/1414969478","profile_link_color":"424242","profile_sidebar_border_color":"000000","profile_sidebar_fill_color":"000000","profile_text_color":"000000","profile_use_background_image":false,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":12,"favorite_count":6,"entities":{"hashtags":[{"text":"IGF2015","indices":[119,127]}],"symbols":[],"user_mentions":[{"screen_name":"vgcerf","name":"vinton g cerf","id":598232506,"id_str":"598232506","indices":[111,118]}],"urls":[]},"favorited":false,"retweeted":false,"lang":"en"},"is_quote_status":true,"retweet_count":7,"favorite_count":5,"entities":{"hashtags":[{"text":"wot","indices":[21,25]}],"symbols":[],"user_mentions":[],"urls":[{"url":"https://t.co/9WEhqqzPEr","expanded_url":"http://www.w3.org/WoT/","display_url":"w3.org/WoT/","indices":[26,49]},{"url":"https://t.co/OZyeQiLitx","expanded_url":"https://twitter.com/rafaelprince/status/664137304739565568","display_url":"twitter.com/rafaelprince/s\u2026","indices":[50,73]}]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"possibly_sensitive_appealable":false,"lang":"en"}

@blessenm blessenm closed this in 709d52a Nov 11, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.