TwitLonger API: Endpoints

Version 2 of the API is in beta testing, these endpoints and what they return is subject to change.

The API provides methods to read and create posts on TwitLonger. It uses OAuth Echo to verify requests that modify data, and all requests require the client to identify itself. Data is returned in JSON format.

Get Post

Display a TwitLonger post. This should only be on user request, you should not automatically load all TwitLonger posts into the user's timeline. The ID should be taken from the trailing end of a TwitLonger link or short URL. For example, tl.gd/bun2lo is the same post as www.twitlonger.com/show/bun2lo and can be retrieved from the API using bun2lo as the ID.

URL:
api.twitlonger.com/2/posts/{id}
Method:
GET
Required Headers:

X-API-KEY: The API key for your application.

Example Response:
{
  "post_time": "2014-01-26 14:03:22",
  "reply_to_id": "54321",
  "short_url": "http://tl.gd/n_2r",
  "screen_name": "stuartgibson",
  "full_url": "http://www.twitlonger.com/show/n_2r",
  "id": "n_2r",
  "twitter_status_id": null,
  "tweet_content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean tincidunt luctus quam, sed fermentum magna (cont) http://tl.gd/n_2r",
  "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean tincidunt luctus quam, sed fermentum magna porttitor in. Quisque luctus magna eget est congue sit amet aliquet nisl fermentum. Cras non libero est, nec volutpat lacus. Nullam vel dolor est. Sed vel ligula et mi dapibus gravida nec in risus. Sed nunc dui, lacinia non consectetur ac, pharetra a lacus. Nunc a dictum felis. Phasellus eget nisi ligula"
}

        

Create Post

Create a new TwitLonger post for the authenticating user. Note that this does not post to Twitter for you, just validates the user and saves the TwitLonger post. You should use the response to then send the link to Twitter. The "tweet_content" in the response should be automatically truncated to the appropriate length, but you are encouraged to verify this before posting to Twitter. Please use the tl.gd short URL version of the link in your post as clients often rely on this rather than the full URL for integration.

URL:
api.twitlonger.com/2/posts
Method:
POST
Required Headers:

X-API-KEY: The API key for your application.

X-Auth-Service-Provider: The URL to verify the identity of the user you are making the request on behalf of. This should always be https://api.twitter.com/1.1/account/verify_credentials.json Requests that do not match this endpoint will be rejected, but additional parameters passed will be honoured.

X-Verify-Credentials-Authorization: This should be the OAuth authentication headers needed to perform the verify credentials request to Twitter. If you need further clarification on this, you should read about the OAuth Echo flow on Twitter. (Note they reference the 1.0 endpoint, not the current 1.1. You must use 1.1)

Required Parameters:

content: The content of the TwitLonger post.

Optional Parameters

reply_to_id: If the TwitLonger post is a reply to another tweet, the ID of that tweet should be supplied.

reply_to_screen_name: If supplying a tweet ID to reply to, you should also supply the screen name of the user the reply is to. Both parameters are required to be accepted.

Example Response:
This will return the same information as the GET method above.

Update Post with Twitter ID

After successfully posting the link to the TwitLonger post for the user, it is very helpful to then update the post on TwitLonger with the Twitter status ID. This makes it easier for threading etc.

URL:
api.twitlonger.com/2/posts/{id}
Method:
PUT
Required Headers:

X-API-KEY: The API key for your application.

X-Auth-Service-Provider: The URL to verify the identity of the user you are making the request on behalf of. This should always be https://api.twitter.com/1.1/account/verify_credentials.json. Requests that do not match this endpoint will be rejected, but additional parameters passed will be honoured.

X-Verify-Credentials-Authorization: This should be the OAuth authentication headers needed to perform the verify credentials request to Twitter. If you need further clarification on this, you should read about the OAuth Echo flow on Twitter. (Note they reference the 1.0 endpoint, not the current 1.1. You must use 1.1)

Required Parameters:

twitter_status_id: The ID of the Twitter post the TwitLonger link was sent to.

Example Response:
This will return the same information as the GET method above.
LN