Introduction

Using our REST API allows you to use your ScribbleLive data any way you want. Calls to our API can be broken down into the following sections:

The script below has to be added to any application which uses our API. This script is currently used to track metrics for your events. In the future we plan to add features that will make it easier to display videos, polls, and discussion comments. You need to replace the id parameter (id=xxxxx) with your event id.

<script type="text/javascript" src="http://embed.scribblelive.com/modules/lib/addons.js?id=xxxxx"></script>

It is highly recommended that API requests are done over HTTPS to prevent passwords from being sent in clear-text.
Current API Endpoint: http://apiv1.scribblelive.com
Current Secure API Endpoint: https://apiv1secure.scribblelive.com

You must have an existing event in order to make use of our API operations.

All date/time values that are entered into parameters or returned in responses are in UTC.

Calls that modify posts, events etc. affect real data and cannot be undone.

Open Source API Projects

You can find links to our API projects from here.

Below is a basic example showing you how to use our API to get live updates from an event. Feel free to use/ modify this code for your own purposes. Here is a live example of this code: http://customerfiles.scribblelive.com.s3.amazonaws.com/api/live_updates_example.html

You will need to replace the event id (highlighted in red) with your event id and also replace the token (highlighted in blue) with your token.

<!DOCTYPE html>
<html>
<head>
<title>ScribbleLive API - Live Updates Example</title>
<meta charset="utf-8">
<script type="text/javascript" src="http://embed.scribblelive.com/modules/lib/addons.js?id=xxxxx"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(document).ready(function(){

var event_id = xxxxx;
var token = "zzzzzzzz";
var LastModified;
var postsArray = new Array();

initial_check();
window.setInterval(function(){posts_check()}, 5000);

function initial_check(){

	url = "http://apiv1.scribblelive.com/event/" + event_id + "/page/last/?Token=" + token + "&PageSize=20&Order=asc&format=json";

	$.ajax({          				
		url: url,
		type:'GET',
		contentType: "application/json",
		dataType: 'jsonp',
		jsonpCallback: 'sl_callback',
		cache: true,
		success: function(data){ 
		$.each(data.Posts, function(c, d){

			$("#insert_posts").append("<li class='post'>" + d.Content + "<br /><span class='meta'>By " + d.Creator.Name + "</span></li>");
			postsArray.push(d.Id);

		});

		LastModified = last_modified(data.LastModified);
		}
	});
}

function posts_check(){
	
	url = "http://apiv1.scribblelive.com/event/" + event_id + "/all/?Token=" + token + "&Format=json&Order=asc&Since=" + LastModified;

	$.ajax({          				
		url: url,
		type:'GET',
		contentType: "application/json",
		dataType: 'jsonp',
		jsonpCallback: 'sl_callback',
		cache: true,
		success: function(data){ 
		$.each(data.Posts, function(c, d){

			if ($.inArray(d.Id, postsArray) === -1){
				$("#insert_posts").prepend("<li class='post'>" + d.Content + "<br /><span class='meta'>By " + d.Creator.Name + "</span></li>");
				postsArray.push(d.Id);
			}

		});

		LastModified = last_modified(data.LastModified);
		}
	});
}

function last_modified(unix){

	var lastmodified =  unix.match(/(\d{13})/g);
	var lastmodified = new Date(lastmodified*1);
	var LastModifiedTimeFormatted = lastmodified.getUTCFullYear() + "/" + (lastmodified.getUTCMonth() + 1) + "/" + lastmodified.getUTCDate() + " " + lastmodified.getUTCHours() + ":" + lastmodified.getUTCMinutes() + ":" + lastmodified.getUTCSeconds();
	lastmodified = encodeURIComponent(LastModifiedTimeFormatted);

	return lastmodified;
}
	
});
</script>
<style>
.post {
	list-style-type:none;
	border: 1px solid #DDD;
	background-color:#EEE;
	padding:5px;
	margin-bottom:10px;
}
.meta {
	font-size:0.8em;
	color:#666;
}
#insert_posts {
	padding:0px;
}
</style>
</head>
<body>
<h1>ScribbleLive API - Live Updates Example</h1>
<ul id="insert_posts"></ul>
</body>
</html>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s