Working with t.co: Best Practices

Updated on Sat, 2012-08-25 12:24

Linking to content within tweets

We recommend the following when rendering links within Tweets:

  • Use the "url" value of a URL entity for the href attribute of an anchor tag.
  • Use the "expanded_url" value of a URL entity for the title attribute of an anchor tag, so that when users hover over the link they see the fully expanded URL.
  • Use the "display_url" value of a URL entity for the displayed text between opening & closing anchor tags. If you prefer not to display our truncated format, use the full "expanded_url" instead.
  • Non-HTML based environments obviously require more creative approaches, but the spirit of t.co should be kept in mind. Display as appropriate for your environment.
  • When a disruption in ability to resolve t.co links occur, it's recommended to display t.co links unless you already have a resolution for the URL. t.co's redirection and malware protection capabilities are fully in tact when these disruptions occur.

Working with tweet input text

  • Request GET help/configuration once daily in your application and cache the "short_url_length" (t.co's current maximum length value) for 24 hours. Cache "short_url_length_https" (the maximum length for HTTPS-based t.co links) and use it as the length of HTTPS-based URLs.
  • If you offer a "remaining character count" feature in a tweet entry input field, consider URLs detected in user input with twitter-text as being equal in length to the current "short_url_length" value.