Public API

Embed a Stream on a Remote Page

Base HTML for embedding

<script type="text/javaScript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javaScript" src="http://stream.snapreplay.com/socket.io/socket.io.js"></script>
<script type="text/javaScript" src="http://cdn.snrly.com/jquery.esn.autobrowse.js"></script>
<script type="text/javaScript" src="http://cdn.snrly.com/jstorage.js"></script>

<script type="text/javaScript">
<!--
var stream_id = 1;
var backfill = 'http://stream.snapreplay.com/stream/'+stream_id+'/OFFSET/10';

function build_html(data) {
  var html = '';
  if (data['content_type'] == 'kill') {
    $('div[id='+data['id']+']').hide();
    return(html);
  }
  if (data['content_type'] == 'image') {
    html = '<div id="' + data['id'] + '" class="container"><div id="p-' + data['id'] + '">' + data['display_name'] + '<br><img src="http://cdn.snrly.com/pics/' + data['file_name'] + '"></div></div>';
  } else {
    html = '<div id="' + data['id'] + '" class="container"><div id="p-' + data['id'] + '">' + data['display_name'] + '<br>' + data['content'] + '</div></div>';
  };
  return(html);
};
  var socket = io.connect('http://stream.snapreplay.com');
  socket.on('u-' + stream_id, function (data) {
    $('#top_placeholder').before(build_html(data['data']));
  });
$(function() {
  $(".items").autobrowse(
    {
        url: function (offset)
        {
            var startpos = $("div[id^='p-']").map(function() { 
                             return this.id.substring(2); }).sort()[0];
            if (!startpos) { startpos = 0 };
            return backfill.replace(/OFFSET/, startpos);
        },
        template: function (response)
        {
            var markup='';
            for (var i=0; i<response.length; i++)
            {
                markup+=build_html(response[i]);
            };
            return markup;
        },
        itemsReturned: function (response) { return response.length; },
        offset: 0,
        max: 100,
        loader: '<div class="loader"></div>',
        useCache: true,
        expiration: 1
    }
  );
});
// -->
</script>
<div class="items">
<div id="top_placeholder"></div>
</div>

Changes that need to be made

var stream_id = 1;
Change this to match the stream ID assigned to your event
/10 at end of backfill
This will fetch 10 items at a time, you can change it to pull more items per fetch if desired.
function build_html(data)
This function controls what the output looks like on the page. Three differnt blocks need to be defined, text, images and video. (Video is currently not supported)

Fields contained in the data payload

stream_id
Integer, the stream ID
display_name
String, the User's selected display name/nickname
content_type
String, image, text, video
time_received
Integer, UTC timestamp
id
Integer, id of the individual item, used to support infinite scrolling
content
String, text message
l_file_name
String, URL of low bandwidth image
file_name
String, URL of 1024 pixel wide image
raw_file_name
String, URL of image as uploaded

Other API Functions

create_account

Create an account

URL: http://api.snapreplay.com/create_account
Method: POST | GET (json)
Returns: User Auth Token
unknown

login_account

Login to an account

URL: http://api.snapreplay.com/login_account
Method: POST | GET (json)
Returns: User Auth Token
unknown

associate_phone

Associate phone with account (login from phone to existing account should automatically do this)

URL: http://api.snapreplay.com/associate_phone
Method: POST
Returns: OK|ERROR
auth_token - REQUIRED
OAuth User Token, not an event token
phone_id - REQUIRED
Android
phone_manufacturer - optional
Android
phone_model - optional
Android

get_local_events

Get a json list of events within a 50 mile radius of the phone.

URL: http://api.snapreplay.com/get_local_events
Method: POST
Returns: json list of event titles + event id
auth_token - REQUIRED
OAuth User Token, not an event token
lat_long - tuple
10.00000000 10.00000000

search_active_events

Get a json list of events within a 50 mile radius of the phone.

URL: http://api.snapreplay.com/get_local_events
Method: POST|GET (json)
Returns: json list of event titles + event id
auth_token - REQUIRED
OAuth User Token, not an event token
lat_long - REQUIRED
10.00000000 10.00000000
search_term
type: string

get_venues

Get a json list of venues within a 50 mile radius of the phone.

URL: http://api.snapreplay.com/get_venues
Method: POST | GET (json)
Returns: json list of venue titles + event id
auth_token - REQUIRED
OAuth User Token, not an event token
lat_long - tuple
10.00000000 10.00000000

login_event

Login to an event

URL: http://api.snapreplay.com/login_event
Method: POST | GET (json)
Returns: Auth Event Token
auth_token - REQUIRED
OAuth User Token, not an event token
event_id - REQUIRED
string
phone_id - REQUIRED
Android

upload_media

Method: POST
URL: http://api.snapreplay.com/upload
api_key - REQUIRED
api_secret - REQUIRED
event_auth_token - REQUIRED
Event Auth Token, not a User Token
phone_id - REQUIRED
Android
content_type - REQUIRED
[text,audio,picture,video]
content - REQUIRED
media
upload_version - REQUIRED
text - equivalent to a user agent string
caption - OPTIONAL
text
Copyright 2012, SnapReplay.com Version: (v0.9.288 released 2012.11.18)