alert("Album members: <b>" . join(", ", $album->data->members) . "</b>"); $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: <b>{$comment->url}</b>"); alert("Reorder the album"); $album->set_members(array($album->data->members[1], $album->data->members[0]))->set("sort_column", "weight")->save(); alert("New order: <b>" . join(", ", $album->data->members) . "</b>"); 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: <b>{$tag->data->relationships->items->members[0]}</b>"); alert("Delete the album and tag"); $album->delete(); $tag->delete(); alert("Done!"); function alert($msg) { print "{$msg} <br/>\n"; flush(); }
$photos = Gallery3::factory($root->url, $auth) ->set("random", "true") ->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: <b>{$tag->data->relationships->items->members[0]}</b>"); alert("Delete the album and tag"); $album->delete(); $tag->delete();