# name of your Rambla user account define('PWD', "xxx"); # password of your Rambla user account define('RASS_SERVER', 'rass.cdnXX.rambla.be'); # either 'rass.cdn01.rambla.be' or 'rass.cdn02.rambla.be' (depending on the subCDN on which your account is located) define('LOCAL_PATH', '/path/to/local/file.mp4'); # add path to local (video) file, to be uploaded to the CDN require_once 'raws_json/meta.php'; require_once 'raws_json/json_client.php'; require_once 'raws_json/meta_service.php'; require_once 'raws_json/rass_service.php'; try { $rass = new RassService(USER, PWD, RASS_SERVER); $meta = new MetaService(USER, PWD); # upload file to CDN (RASS PUT item) $item1 = $rass->createItem("/test/content/", "myfile_one.mp4", LOCAL_PATH, True); $item2 = $rass->createItem("/test/content/", "myfile_two.mp4", LOCAL_PATH, True); # create content instance for item1 $f = array(); $f[] = new FileObj($item1->entry->content->params->path); $m = array(); $m[] = new MetaObj("Title", "rss", "My first file", "en"); $m[] = new MetaObj("Description", "rss", "Description of my first file", "en"); $content_obj1 = new MetaContent("myfile_one", $f, null, $m); $content = $meta->createContent($content_obj1->to_entry()); $content_obj1->from_entry($content); echo "\nCreated new content instance with name = " . $content_obj1->name . "\n"; # create content instance for item2 $f = array(); $f[] = new FileObj($item2->entry->content->params->path, "video"); $m = array();
define('PWD', 'xxx'); # your user account pwd define('RASS_SERVER', 'rass.cdn0x.rambla.be'); # either 'rass.cdn01.rambla.be' or 'rass.cdn02.rambla.be' (depending on the subCDN on which your account is located) # all RASS API methods (except HEAD) will raise an exception if they don't return an HTTP SUCCESS CODE (200,201,204) try { # Instantiate an object that manages the RASS connection, passing it your login credentials and the base service uri $rass = new RassService(USER, PWD, RASS_SERVER); # Creates a "tutorial2" directory below your root dir $dir = $rass->createDir("tutorial2"); # Retrieve the entry's "path" param echo "Created directory with path: " . $dir->entry->content->params->path . "\n"; # Note: the URL for accessing this new dir resource is available as the entry's id echo "New dir resource can be accessed at the URL: " . $dir->entry->id . "\n"; # Uploads the local file as 'taste.mp4' to the "tutorial2" directory on the CDN $item = $rass->createItem($dir->entry->content->params->path, "taste.mp4", LOCAL_FILE); # Retrieve the entry's "path" attribute echo "\nCreated file with path: " . $item->entry->content->params->path . "\n"; # Retrieve the filename on the CDN echo "Filename: " . $item->entry->content->params->filename . "\n"; # Get the location of the file on the CDN from the entry's 'enclosure' link echo "Public download location of the uploaded file: " . $rass->getEnclosureLink($item) . "\n"; # Note: the URL for accessing this new item resource is available as the entry's id echo "New dir resource can be accessed at the URL: " . $item->entry->id . "\n"; # PUT the same file for a second time => RASS will add a numerical suffix $item = $rass->createItem($dir->entry->content->params->path, "taste.mp4", LOCAL_FILE); # Retrieve the entry's "path" attribute echo "\nCreated file with path: " . $item->entry->content->params->path . "\n"; # Retrieve the filename on the CDN echo "Filename: " . $item->entry->content->params->filename . "\n"; # Get the location of the file on the CDN from the entry's 'enclosure' link
# name of your Rambla user account define('PWD', "xxx"); # password of your Rambla user account define('RASS_SERVER', 'rass.cdnXX.rambla.be'); # either 'rass.cdn01.rambla.be' or 'rass.cdn02.rambla.be' (depending on the subCDN on which your account is located) define('LOCAL_PATH', '/path/to/local/file.mp4'); # add path to local (video) file, to be uploaded to the CDN require_once 'raws_json/meta.php'; require_once 'raws_json/json_client.php'; require_once 'raws_json/meta_service.php'; require_once 'raws_json/rass_service.php'; try { $meta = new MetaService(USER, PWD); $rass = new RassService(USER, PWD, RASS_SERVER); # upload files to CDN (RASS PUT item) $item1 = $rass->createItem("/test/content/", "big_buck_bunny.mp4", LOCAL_PATH, True); $item1b = $rass->createItem("/test/content/", "big_buck_bunny.jpg", LOCAL_PATH, True); $item2 = $rass->createItem("/test/content/", "sintel.mp4", LOCAL_PATH, True); # create vocabs if (!$meta->vocabExists("media")) { $meta->createVocab("media", "http://search.yahoo.com/mrss/"); } if (!$meta->vocabExists("myvocab")) { $meta->createVocab("myvocab", "http://myvocab.org/ns/"); } # Create content instance with multiple languages for "/test/content/big_buck_bunny.mp4" $content_obj1 = new MetaContent("big_buck_bunny"); $content_obj1->add_file_obj($item1->entry->content->params->path); $content_obj1->add_file_obj($item1b->entry->content->params->path); $content_obj1->add_meta_obj("title", "media", "Big Buck Bunny", "en"); $content_obj1->add_meta_obj("description", "media", "Big Buck Bunny is a short computer animated film by the Blender Institute, part of the Blender Foundation.", "en");
# your user account pwd define('RASS_SERVER', 'rass.cdn0x.rambla.be'); # either 'rass.cdn01.rambla.be' or 'rass.cdn02.rambla.be' (depending on the subCDN on which your account is located) # all RASS API methods (except HEAD) will raise an exception if they don't return an HTTP SUCCESS CODE (200,201,204) try { # Instantiate an object that manages the RASS connection, passing it your login credentials and the base service uri $rass = new RassService(USER, PWD, RASS_SERVER); ## TUTORIAL PRE-CONFIG: FIRST CREATE DIRECTORY + UPLOAD FILES TO HAVE SOME TEST-DATA # Create a "tutorial6" directory under the root-directory $item = null; $dir = $rass->createDir("tutorial6", True); echo "Created directory with path: " . $dir->entry->content->params->path . "\n"; $ctr = 1; # Upload the local file 15 times as 'testXX.mp4' to the "tutorial6" directory (creating some test data) while ($ctr < 16) { $item = $rass->createItem($dir->entry->content->params->path, "test{$ctr}.mp4", LOCAL_FILE); echo "Created file with path: " . $item->entry->content->params->path . "\n"; $ctr += 1; } ## GETTING LINK ELEMENTS FOR AN ENTRY # Directly getting at an item entry's link elements echo "\nGetting all link elements for entry with path: " . $item->entry->content->params->path . "\n"; foreach ($item->entry->link as $link) { echo "\nType of relation: " . $link->rel; echo "\nLink URI: " . $link->href; echo "\nExpected type: " . $link->type . "\n"; } # Using a helper method to get to an entry's enclosure URL echo "\nGetting enclosure link (= download location of the file on the CDN) via helper method: " . $rass->getEnclosureLink($item) . "\n"; ## GETTING LINK ELEMENTS FOR A FEED # Retrieve a list of the files inside the 'tutorial6' sub-directory
# name of your Rambla user account define('PWD', "xxx"); # password of your Rambla user account define('RASS_SERVER', 'rass.cdnXX.rambla.be'); # either 'rass.cdn01.rambla.be' or 'rass.cdn02.rambla.be' (depending on the subCDN on which your account is located) define('LOCAL_PATH', '/path/to/local/file.mp4'); # add path to local (video) file, to be uploaded to the CDN require_once 'raws_json/meta.php'; require_once 'raws_json/json_client.php'; require_once 'raws_json/meta_service.php'; require_once 'raws_json/rass_service.php'; try { $meta = new MetaService(USER, PWD); $rass = new RassService(USER, PWD, RASS_SERVER); # upload file to CDN (RASS PUT item) $item = $rass->createItem("/test/content/", "big_buck_bunny.mp4", LOCAL_PATH, True); # create content instance without metadata $content_obj = new MetaContent("big_buck_bunny"); $content_obj->add_file_obj($item->entry->content->params->path); $content = $meta->createContent($content_obj->to_entry()); echo "\nCreated new content instance with name = " . $content->entry->content->params->name . "\n"; # add tags to the content instance $content_obj->from_entry($content); $content_obj->set_tags(array("bunny", "animation", "Blender")); $content = $meta->updateContent($content_obj->to_entry()); echo "\nAdded tags to content instance with name = " . $content_obj->name . "\n"; # get content instance $content = $meta->getContentInstance($content_obj->name); $content_obj->from_entry($content); echo "\nRetrieved content instance with id = " . $content->entry->id . " and tags: "; foreach ($content_obj->get_tags() as $t) {
# name of your Rambla user account define('PWD', "xxx"); # password of your Rambla user account define('RASS_SERVER', 'rass.cdnXX.rambla.be'); # either 'rass.cdn01.rambla.be' or 'rass.cdn02.rambla.be' (depending on the subCDN on which your account is located) define('LOCAL_PATH', '/path/to/local/file.mp4'); # add path to local (video) file, to be uploaded to the CDN require_once 'raws_json/meta.php'; require_once 'raws_json/json_client.php'; require_once 'raws_json/meta_service.php'; require_once 'raws_json/rass_service.php'; try { $rass = new RassService(USER, PWD, RASS_SERVER); $meta = new MetaService(USER, PWD); # upload file to CDN (RASS PUT item) $item1 = $rass->createItem("/test/content/", "myfile_with_meta.mp4", LOCAL_PATH, True); $item2 = $rass->createItem("/test/content/", "myfile_no_meta.mp4", LOCAL_PATH, True); # create content instance $f = array(); $f[] = new FileObj($path = $item1->entry->content->params->path, $media_type = "video"); $content = new MetaContent($name = "myfile_with_meta", $file_objs = $f); $content->tags = array("een", "twee", "drie"); $content_obj = $meta->createContent($content->to_entry()); $content->from_entry($content_obj); echo "\nCreated new content instance with name = " . $content->name . "\n"; # get contentdir feed echo "\n\nGetting contentdir list..."; $feed = $meta->getContentdirList("/"); foreach ($feed->feed->entry as $e) { if ($e->content->params->name) { echo "\n* retrieved content instance: " . $e->id . " with name = " . $e->content->params->name;