Пример #1
0
 }
 # Create content instance without meta objects for "/test/content/sintel.mp4"
 $content_obj2 = new MetaContent("sintel");
 $content_obj2->add_file_obj($item2->entry->content->params->path);
 $content = $meta->createContent($content_obj2->to_entry());
 echo "\nCreated new content instance with name = " . $content->entry->content->params->name . "\n";
 # Update content instance, adding meta objects
 $content_obj2->from_entry($content);
 $content_obj2->add_meta_obj("title", "media", "Sintel");
 $content_obj2->add_meta_obj("description", "media", "Sintel (code-named Durian) is a short computer animated film by the Blender Institute, part of the Blender Foundation.");
 $content_obj2->add_meta_obj("tag", "myvocab", "animation", "en");
 $content = $meta->updateContent($content_obj2->to_entry());
 echo "\nAdded meta objects to content instance with name = " . $content->entry->content->params->name . "\n";
 # search for content
 echo "\n\nGetting content list, search on 'iqmeta=blender' ...";
 $feed = $meta->getContentList('iqmeta=blender');
 foreach ($feed->feed->entry as $content_entry) {
     $content_obj = new MetaContent();
     $content_obj->from_entry($content_entry);
     echo "\n\nRetrieved content instance with id = " . $content_obj->id . " and meta objs: ";
     foreach ($content_obj->get_meta_objs() as $m) {
         echo "\n- meta obj with vocab = {$m->vocab}, meta_name = {$m->meta_name}, text = {$m->text}, lang = {$m->lang}";
         if ($m->has_attrs()) {
             echo "\n   meta obj attrs:";
             foreach ($m->get_attrs() as $key => $value) {
                 echo "\n   * {$key}:{$value}";
             }
         }
     }
 }
 echo "\n... finished retrieving content instances.\n";
Пример #2
0
    # 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) {
        echo "\n* " . $t;
    }
    # get content feed
    echo "\n\nGetting content list...";
    $feed = $meta->getContentList("tag=animation");
    foreach ($feed->feed->entry as $content_entry) {
        echo "\n* retrieved content: " . $content_entry->id . " with name = " . $content_entry->content->params->name;
    }
    echo "\n... finished retrieving content instances.\n";
    # delete content instance + file from CDN
    $meta->deleteContent($content_obj->name);
    echo "\nDeleted content with name: " . $content_obj->name . "\n";
} catch (Exception $e) {
    echo "\nAn exception occurred with code = " . $e->getCode();
    echo "\nError msg = " . $e->getMessage();
}