Skip to content

Push Server [Proposed]

James Duffy edited this page May 17, 2013 · 5 revisions

Overview

The number 1 requested feature from Tweet Lanes users is notifications. In version 1.6 we will introduce polling notifications. We want to go further and add push notifications, but due to the cost of running a server we are considering releasing an open source server application for our loyal users to run independently.

The server application will need to do the following:

  1. Accept a POST request from Tweet Lanes to register for push notifications.
  2. Accept a DELETE request from Tweet Lanes to stop push notifications.
  3. Open streaming connections to Twitter and App.net for the users registered for notifications.
  4. Send notifications to Tweet Lanes using Google's Cloud Messaging platform.

Registering a user for push notifications

POST /api/1/register

{
  "token":"TOKEN",
  "accounts": [
    { "type":"TWITTER/ADN", "username":"@USERNAME" }
  ],
  "gcm_registration_id": "REGISTRATION_ID"
}

Unregistering for push notifications

POST /api/1/unregister

{
  "token":"TOKEN",
  "accounts": [
    { "type":"TWITTER/ADN", "username":"@USERNAME" }
  ]
}

Check if push notifications are turned on for specific user

GET /api/1/user

{
  "token":"TOKEN",
  "accounts": [
    { "type":"TWITTER/ADN", "username":"@USERNAME" }
  ],
}

Become an authorized user

The server will be secured by a password to keep unauthorized users from using it. The server will create and reply with a token for future requests.

The implementation of the password is up to the application. It can either be a server-wide password or created per user. The open source server application will have a server-wide password.

POST /api/1/authorize

{
  "password":"SERVER_PASSWORD"
}

If the password was correct the server response will look similar to below:

{
  "token":"TOKEN"
}

Possible HTTP Status Codes

  • 200 OK -- The request was successful
  • 400 Bad Request -- The request was malformed in some way.
  • 401 Unauthorized -- You are not authorized to use this server.
  • 404 Not Found -- The requested resource was not found.
  • 429 Too Many Requests -- The request could not be completed because you are making to many requests.
  • 500 Internal Server Error -- An unexpected error has occurred. Try your request again.