Revver Developer Center



Upload Tutorial

Posted by Jim

Related Topics: Uploading, Tutorials



The Revver XML-RPC API provides a simple mechanism for uploading videos. The two XML-RPC API methods that are part of this mechanism are video.create() and video.getUploadTokens(). In this tutorial, we will review both, and explain how to use them properly, as well as how to use the flash uploader widget.

video.getUploadTokens()

The very first step required in order to upload a video is for the user to request a video upload token. The video.getUploadTokens function can return multiple tokens at a time, so the first parameter is count. The second parameter is actually optional, and like all the “options” in the API, it takes a struct, even though it has only one key, “owner”. This parameter is used by the API to determine who the video is owned by, and when building video portals with child users, this becomes an important feature. An owner is assumed to be a child users of the API user, and an “invalid owner” error will be thrown if the API user does not have a child user with the given name.

A common mistake here is to put the owner name that is the same as the API user. The API will see this as the child user and not as the API user, so if you have an API user “myusername”, then the owner will be assumed to be the actual user “myusername@myusername” which will likely not have the expected results.

Also, the return from this function will always be an array. The first element is a string indicating the URL to which you must POST the actual file, and the second element is itself an array (even if you only requested 1 token) of tokens.

i.e.

Array = [ ‘httpupload.revver.com’, [ ‘asdf897dasfdfh32dsa89f’] ]
(this is only an example, your token will look different).

video.create()

Once you’ve gotten your token, you can now create the meta-data for your video. Without meta-data, the video will never move past the “uploading” stage into processing, but you can run video.create() either before or after your file gets uploaded, so you could create a “bulk upload” tool if you wanted that processed multiple sets of video meta data then sent all the files to the server at once.

video.create takes 4 parameters, and an optional options struct. The first param is the token, the second the title, the third is an array of keywords and the fourth parameter is a RECOMMENDATION for age restriction that is passed to our review team. Additional meta-data is included in the options struct. Other than credits, url, description and author, there is also a “references” id which refers to another video id. This is useful for creating “video responses”.

Uploading Videos

Once you’ve got an upload token, you can upload your physical media. The return from the video.getUploadToken() function includes the URL of the upload server.

For each individual token returned, the URL for upload is the upload server and then the token and a “urlRedirect” querystring that is the absolute URL where the upload server will redirect after a successful upload. When redirecting the server will add a “success” variable to your URL. This variable is either true or false. No other data is sent.

i.e.:

http://httpupload.revver.com/asdf897dasfdfh32dsa89f?urlRedirect=http://www.myserver.com/upload_complete.php

HTML Forms vs. Flash Uploader

Once you have your URL and token, you can create an upload form.

i.e.

<form action=”http://httpupload.revver.com/asdf897dasfdfh32dsa89f?urlRedirect=http://www.myserver.com/upload_complete.php
” method=”POST” type=”multipart/form-data”>
<input type=”file” name=”file”/>

<input type=”submit”/>
</form>

If you prefer, you can use the Revver flash uploader, which is documented at http://developer.revver.com/widget/upload.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.