set("name", "My Tag") ->create($tags->url, $auth); alert("Created tag: {$tag->url}"); $album = Gallery3::factory() ->set("type", "album") ->set("name", "Sample Album") ->set("title", "This is my Sample Album") ->create($root->url, $auth); alert("Created album: {$album->url} {$album->data->entity->title}"); alert("Modify the album"); $album ->set("title", "This is the new title") ->save(); alert("New title: {$album->data->entity->title}"); for ($i = 0; $i < 2; $i++) { $photo = Gallery3::factory() ->set("type", "photo") ->set("name", "Sample Photo.png") ->set("title", "Sample Photo") ->set_file("test1.png") ->create($album->url, $auth); alert("Uploaded photo: {$photo->url}"); } $album->load(); alert("Album members: " . join(", ", $album->data->members) . ""); alert("Replace the data file"); $photo->set_file("test2.png") ->save(); $comment = Gallery3::factory() ->set("item", $album->data->members[0]) ->set("type", "comment") ->set("text", "This is a random comment-- whee!") ->create($comments->url, $auth); alert("Comment: {$comment->url}"); alert("Reorder the album"); $album ->set_members(array($album->data->members[1], $album->data->members[0])) ->set("sort_column", "weight") ->save(); alert("New order: " . join(", ", $album->data->members) . ""); alert("Search for the photo"); $photos = Gallery3::factory($root->url, $auth) ->set("name", "Sample") ->load(); alert("Found: {$photos->data->members[0]}"); alert("Grab a random photo"); $photos = Gallery3::factory("{$root->url}?random=true", $auth) ->load(); alert("Found: {$photos->data->members[0]}"); alert("Tag the album (using the album's relationships: {$album->data->relationships->tags->url})"); $tag_relationship1 = Gallery3::factory() ->set("tag", $tag->url) ->set("item", $root->url) ->create($album->data->relationships->tags->url, $auth); alert("Tag: {$tag_relationship1->url}"); alert("Tag the photo (using the tag's relationships: {$tag->data->relationships->items->url})"); $tag_relationship2 = Gallery3::factory() ->set("tag", $tag->url) ->set("item", $photo->url) ->create($tag->data->relationships->items->url, $auth); alert("Tag: {$tag_relationship2->url}"); alert("Un-tag the photo"); $tag_relationship2->delete(); $tag->load(); alert("1 remaining tag: {$tag->data->relationships->items->members[0]}"); alert("Delete the album and tag"); $album->delete(); $tag->delete(); alert("Done!"); function alert($msg) { print "$msg
\n"; flush(); } ?>