예제 #1
0
$meta = array();
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
    $filename = $data[0];
    $meta[$filename]['filename'] = $data[0];
    $meta[$filename]['grammar_tags'] = explode('|', $data[1]);
    $meta[$filename]['english_title'] = $data[2];
    $meta[$filename]['japanese_title'] = $data[3];
}
fclose($handle);
foreach ($meta as $filename => $m) {
    $title = $filename . '.mov';
    $res = $client->search('@title:' . $title);
    $url = $res->app_root . $res->items[0]->links->metadata;
    if ($url) {
        $pairs = array();
        foreach ($m as $k => $v) {
            if (is_array($v)) {
                $vset = array();
                foreach ($v as $str) {
                    $vset[] = '"' . $str . '"';
                }
                $pairs[] = '"' . $k . '":[' . join(',', $vset) . ']';
            } else {
                $pairs[] = "\"{$k}\":\"{$v}\"\n";
            }
        }
        $json = "{" . join(',', $pairs) . "}\n";
        $rp = DaseClient::post($url, $json, $user, $pass, 'application/json');
        print_r($rp);
    }
}
예제 #2
0
 public static function createCollection($host, $collection_name, $user, $pass)
 {
     $ascii = self::dirify($collection_name);
     $entry = DaseClient::makeAtom($ascii, $collection_name, array());
     $entry = DaseClient::addCategory($entry, 'collection', 'http://daseproject.org/category/entrytype');
     //could have been retrieved from base AtomPub service doc:
     $url = $host . '/collections';
     $resp = DaseClient::post($url, $entry, $user, $pass, 'application/atom+xml');
     return $resp;
 }
예제 #3
0
<?php

include 'DaseClient.php';
ini_set('memory_limit', '700M');
$user = '******';
$pass = DaseClient::promptForPassword($user);
$client = new DaseClient('waller');
$uris = $client->getCollectionItemUris();
foreach (explode("\n", $uris) as $uri) {
    $res = DaseClient::get($uri . '.atom', $user, $pass);
    if ('200' == $res[0]['http_code']) {
        $atom_entry = $res[1];
        if ('image/jpeg' == $client->getAdminMetadata($atom_entry, 'admin_mime_type')) {
            $item_type_link = $client->getLinkByRel($atom_entry, 'http://daseproject.org/relation/edit-item_type') . "\n";
            $post_res = DaseClient::post($item_type_link, 'photo', $user, $pass, 'text/plain');
            //print HTTP code and response message
            print $post_res[0]['http_code'] . ' ' . $post_res[1] . "\n";
        }
    } else {
        print $res[0]['http_code'] . ' ' . $res[1] . "\n";
    }
}