PandaStream API ColdFusion Wrapper

On November 11, 2011, in ColdFusion, Railo, by Anuj Gakhar

In my recent project, one of my tasks is to encode videos in multiple formats. And we decided to use PandaStream for the job. PandaStream is a flexible and highly scalable cloud video encoding API. Here is en entire list of their supported file formats.

They seem to have a fairly decent REST API, which obviously means that in order to consume it, I had to write a API wrapper. So, I did 🙂 The code is available on github.

Here is some sample usage on how you can use the API client :-

To initialise the CFC, you pass in the required parameters :-

[cf]ACCESS_KEY = "access_key";
SECRET_KEY = "secret_key";
CLOUD_ID = "cloud_id";

panda = createObject("com.anujgakhar.PandaStreamAPI").init(
cloud_id="#CLOUD_ID#",
access_key="#ACCESS_KEY#",
secret_key="#SECRET_KEY#"
);[/cf]

A Sample GET Request

[cf]panda.get(‘/videos.json’);
or
panda.get(‘/videos/:id.json’)
[/cf]

A Sample DELETE Request

[cf]panda.delete(‘/videos/:id.json’);[/cf]

A Sample PUT Request

[cf]params = {};
params.name = "updated_from_api";
panda.put(‘/clouds/#CLOUD_ID#.json’, params);[/cf]

A Sample POST Request

[cf]params = {};
params.source_url = "http://example.com/path/to/video.mp4";
newVideo = panda.post(‘/videos.json’, params);[/cf]

Enjoy!

Tagged with:  

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2011 Anuj Gakhar
%d bloggers like this: