This is our twitter application which handles all tweets from our projects.

Please note: This service is not publically available for obvious reasons, however it may be possible to expose this service at a later date.

Calling the service

Access to any of the endpoints on this service requires an Authorization request header included with the API key included.

curl -H 'Authorization: {{key}}' http://api.area51.onl/twitter/{{endpoint}}

Configuration

As well as the Authorization key, this service also requires the following items of configuration for the service to work:

name
A unique name for this entry, usually the twitter handle
key
The Authorization key
appId
The twitter consumer_key for the application
appsecret
The twitter consumer_secret for the application
secret
The twitter secret for the account
token
The twitter token for the account

This service will only have access to the account that the twitter app in use has (specified by appId/appsecret).

Posting a tweet

The tweet endpoint permits the submission of a tweet to twitter.

$ curl -H 'Authorization: {{key}}' -d '{{tweet}}' http://api.area51.onl/twitter/tweet
{{response}}

The tweet payload is a JSON object defining the tweet. It consists of two mandatory entries, "name" which is the name of the account to use and "status" which contains the text to tweet.

There is a third optional entry, "media" which contains an image to be attached to the tweet. If provided, the value is the image data in base64 format. If more than one image is to be included, then the value is an array of base64 strings, one per image.

The response will be a JSON object containing either details of the tweet (as returned by Twitter) or an error message.

Recipes

Tweet a simple message

This recipe will tweet {{status}} for {{name}}

$ curl -s -H 'Authorization: {{key}}' \
    -d "{\"name\":\"{{name}}\",\"status\":\"{{status}}\"}" \
    http://api.area51.onl/twitter/tweet

Tweeting an image

This recipe will tweet {{status}} and an {{image}} for {{name}}

$ curl -s -H 'Authorization: {{key}}' \
    -d "{\"name\":\"{{name}}\",\"status\":\"{{status}}\",\"media\":\"$(base64 -w 0 {{image}})\"}" \
    http://api.area51.onl/twitter/tweet