Skip to content
Timothy Duffy edited this page Jul 10, 2014 · 60 revisions

##API Documentation v0.1##


###uploadmedia.json###

HTTP POST:

<form action="/uploadmedia.json" method="post" accept-charset="utf-8" enctype="multipart/form-data">

    <input id="clientid" name="clientid" type="text" value="<clientid>" />
    <input id="mediatype" name="mediatype" type="text" value="<mediatype>">

    <input id="mediafile" name="mediafile" type="file" value="<filename>" /> <!-- optional -->
    <input id="mediatext" name="mediatext" type="text" value=""> <!-- optional -->
    <input id="mediacaption" name="mediacaption" type="text" value=""> <!-- optional -->

    <input type="submit" value="submit" />
</form>

Field Descriptions:

clientid:

    This is of type text, and is the unique id of the client.  This is a uuid that is generated by the 
    client and is associated with a user within the database.  Event if a user is 'validated' their 
    unique clientid is still used to identify them.

mediatype:

    This field holds the type of the media.  Valid types include:

        text - a text post.  there is no limit on it's length.
        audio - an audio recording (should be in mp3 format)
        video - a video recording (should be in mpg format)
        image - an image (should be in jpg format)

    If a mediatype of 'text' is used, then the mediatext field must contain a non-zero length string.  If
    any other mediatype is used, then the mediafile field must contain file data.  Not following these
    rules will produce a { "success": false } response.


mediafile:

    This is of type file, and will be the media object that is being uploaded.  This is an optional field,
    but the mediatype filed must be 'text' if this is not included, else { "success": false } will be 
    returned.

mediatext

    This is of type text, and will hold the text of the media post.  This is an optional field, but the
    mediatype field must be 'audio', 'video', or 'image' if this is not include, else a 
    { "success": false } will be returned.

mediacaption

    This is of type text, and will hold an additional description of the media type.  This is an optional
    and does not need to be included.

Response:

Successful upload:

    {"mediaid": "4ebbb6c0-bd4c-43fc-8242-5aec49989f61", "success": true}

Unsuccessful upload:

    { "success": false }

###publishpost.json###

HTTP Post:

<form action="/publishpost.json" method="post" accept-charset="utf-8" enctype="multipart/form-data">

    <input id="clientid" name="clientid" type="text" value="{0}">
    <input id="assignmentid" name="assignmentid" type="text" value="{0}">
    <input id="languagecode" name="languagecode" type="text" value="en">
    <input id="location" name="location" type="text" value="{1}">
    <input id="mediaobjects" name="mediaobjects" type="text" value="{2}">

    <input type="submit" value="submit" />
</form>

Field Descriptions:

clientid:

    This is of type text, and is the unique id of the client.  This is a uuid that is generated by the 
    client and is associated with a user within the database.  Event if a user is 'validated' their 
    unique clientid is still used to identify them.

assignmentid:

    This is of type text, and holds the optional assignment id the post is responding to.  Since user 
    posts can be responses to assignments, this field will hold the assignment id that the post is
    responding to.

languagecode:

    This is of type text, and holds the two letter language code the post is in.  Language codes must
    match those codes that exist within the languages table within the database.  Valid values currently
    are:

        en - English
        es - Español

    Note: If responding to an assignment, the response post should have the same language code as the
    question being asked.

location:

    This is of type text, and is a json object that holds the latitude and longitude of the user making
    the post.  The json dictionary has the flowing keys:

        {
            "lat": 43.1656,
            "lng": -77.6114
        }

    Both keys must be present, and be valid latitude/longitude values.

mediaobjects:

    This is of type text, and is a json object that holds an array of mediaobject id's.  The json array
    looks like this:

        [
            "4ebbb6c0-bd4c-43fc-8242-5aec49989f61",
            "b71d403b-caf1-470c-ad29-51229526fe1e"
        ]

    The supplied id's must be associated with valid mediaobject uploads, and should only come from the
    uploadmedia.json response json dictionary.

###clientlogs.json###

NOTE: This is for debug purposes only, and will be removed in production code. Calling eventlogs.json will produce a json object will logs of events within the system. Here is an example response: [ { "event_log_id": 1, "user_id": 1, "event_type": "http_request", "event_datetime": "2014-07-10 13:39:15.492121", "details": { "date_time": "2014-07-10 13:39:15", "media_id": "b94d18c7-b628-4c95-b6eb-6c83c4e360db", "success": true, "media_caption": "", "new_user": true, "file_name": "", "media_text": "", "url": "uploadmedia.json", "client_id": "19ce6abd-d4c1-4d89-a87c-73a21bd56ab3", "media_type": "text" } }, { "event_log_id": 2, "user_id": 1, "event_type": "new_user_created", "event_datetime": "2014-07-10 13:39:15.511134", "details": { "method": "uploadmedia.json", "client_id": "19ce6abd-d4c1-4d89-a87c-73a21bd56ab3" } }, { "event_log_id": 3, "user_id": 1, "event_type": "http_request", "event_datetime": "2014-07-10 13:39:24.132955", "details": { "media_objects": [ "b94d18c7-b628-4c95-b6eb-6c83c4e360db" ], "pos_id": 1, "success": true, "new_user": false, "assignmentid": "19ce6abd-d4c1-4d89-a87c-73a21bd56ab3", "datetime": "2014-07-10 13:39:24", "url": "publishpost.json", "location": { "lat": 44, "lng": -77 }, "client_id": "19ce6abd-d4c1-4d89-a87c-73a21bd56ab3", "language_code": "en" } } ]

Clone this wiki locally