{"id":425,"date":"2013-09-26T17:35:45","date_gmt":"2013-09-26T17:35:45","guid":{"rendered":"http:\/\/composer.io\/site\/?p=425"},"modified":"2017-02-13T19:48:34","modified_gmt":"2017-02-13T19:48:34","slug":"twitter-and-their-shortener","status":"publish","type":"post","link":"https:\/\/composer.io\/site\/2013\/09\/26\/twitter-and-their-shortener\/","title":{"rendered":"Twitter and their &#8220;shortener&#8221;"},"content":{"rendered":"<p><em>tl;dr<\/em> Composer just got better at posting tweets, so post full urls instead of shortening.<\/p>\n<p>Twitter automatically parse out any domain name or url in a tweet and replaces it with a <code>t.co<\/code> link. If you type something like <code>twitter.com<\/code> your 11 character domain gets converted into (currently) a 22 character <code>t.co<\/code> link.<\/p>\n<p>Until today, Composer wasn&#8217;t very good at understanding this. Sometimes, it would shorten your post before sending it to twitter when it wasn&#8217;t necessary. And worse, with the introduction of <a title=\"Composer posts images\" href=\"http:\/\/composer.io\/site\/2013\/09\/15\/composer-posts-images\/\" target=\"_blank\">images<\/a>, sometimes posts to twitter would fail. If you add an image, you lose (currently) 23 characters from your tweet because twitter posts a link to the image (22) plus a space (1).<\/p>\n<p>So, from today, we&#8217;ve built custom handlers just for twitter. We parse out any domain or url, replace it with (currently) 23 characters, and then check if your tweet is &lt;140.<\/p>\n<h2>Shortlinking<\/h2>\n<p>This means, if you post a massive url to twitter, it gets auto shortened on twitter&#8217;s side, and now Composer is smart enough to figure that out. So if you&#8217;re posting links to Facebook, Twitter and WordPress, post the full url, no need to use a shortener.<\/p>\n<p>Two caveats, we&#8217;re a little conservative because twitter&#8217;s <code>t.co<\/code> links are 22 characters for <code>http<\/code> links and 23 for <code>https<\/code> links. So we assume all links are 23 just to be on the safe side. Also, we parse out all domains (like <code>composer.io<\/code> or <code>github.io<\/code>) which Twitter doesn&#8217;t. I filed a <a title=\"Bug in Twitter's text conformance tests, two letter top level domains are not linked or tested\" href=\"https:\/\/github.com\/twitter\/twitter-text-conformance\/issues\/59\" target=\"_blank\">bug<\/a>.<\/p>\n<p>This was made substantially easier thanks to <a title=\"Twitter-Text-PHP, a PHP implementation of Twitter's text parsing\" href=\"https:\/\/github.com\/mzsanford\/twitter-text-php\" target=\"_blank\">twitter-text-php<\/a>, thanks to its authors.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>tl;dr Composer just got better at posting tweets, so post full urls instead of shortening. Twitter automatically parse out any domain name or url in a tweet and replaces it with a t.co link. If you type something like twitter.com your 11 character domain gets converted into (currently) a 22 character t.co link. Until today, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[36,37,59,13],"class_list":["post-425","post","type-post","status-publish","format-standard","hentry","category-tech","tag-shorteners","tag-shortlinks","tag-t-co","tag-twitter"],"_links":{"self":[{"href":"https:\/\/composer.io\/site\/wp-json\/wp\/v2\/posts\/425"}],"collection":[{"href":"https:\/\/composer.io\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/composer.io\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/composer.io\/site\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/composer.io\/site\/wp-json\/wp\/v2\/comments?post=425"}],"version-history":[{"count":10,"href":"https:\/\/composer.io\/site\/wp-json\/wp\/v2\/posts\/425\/revisions"}],"predecessor-version":[{"id":436,"href":"https:\/\/composer.io\/site\/wp-json\/wp\/v2\/posts\/425\/revisions\/436"}],"wp:attachment":[{"href":"https:\/\/composer.io\/site\/wp-json\/wp\/v2\/media?parent=425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/composer.io\/site\/wp-json\/wp\/v2\/categories?post=425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/composer.io\/site\/wp-json\/wp\/v2\/tags?post=425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}