Skip to content

API Moduls

theroggio edited this page Dec 1, 2017 · 6 revisions

API Moduls

API Moduls are divided into folders, one for each social network. Inside we can find a brief explanation on how this moduls work and how to use it individually from terminal (README.md) and requirements they need to work.

Two separated files are used to implement PorchettaSocial functions.

Authentication Websocket

This file is the websocket endpoint of API Moduls, the other endpoint is the html page on client side. Moduls wait, from the moment the server starts, messages in the following format: command | parameters .... The |, like on any other message format, represents the flag (0xFF).

The command field has to be one between auth and verify_pin.

Auth Command

API Moduls use the oAuth service to obtain request_token and request_token_secret that will be needed during the verify_pin phase. This command doesn't need any parameters, but it will return three:

  • Authorization Url

  • Request Token

  • Request Token Secret

This response is sent throught websocket with format: api_id | auth | authroization_url | request_token | request_token_secret. These are saved as Cookies by the Main Server.

For further informations about oAuth services: oAuth .

Verify Pin Command

This command requires following parameters: pin | request_token | request_token_secret and its response is in the following format: api_id | verify_pin | first_token | second_token; these two tokens will be necessary during the upload od the posts, they granted we have your authorization to use your profile and post images/textes.

Social Queue

This files handles the queue of the specific social media, so its responsable of the effective upload of the posts. It uses oAuth services because mostly of social networks require you're authorizated to post and queues are created throught AMQP. Every API Moduls is referred to a single queue which receives messages from Main Server thanks to specific routing keys.

Messages format: msg_id | command | first_token | second_token | text/photo_description | photo_binary_file.

Where command should be 'upload_post' and tokens are obatined from cookies, if they're not found it means users are logged out and they need to log in and authroize us to post. While Twitter and Tumblr allow text posts, so their moduls work with just the first five parameters; Flickr doesn't support this, so it need all six parameters.

To know more about how we get text/photo_description and photo_binary_file : PorchettaSocial website .

Links