diff --git a/client/Gallery3.php b/client/Gallery3.php
index e7b9337a..d3557948 100644
--- a/client/Gallery3.php
+++ b/client/Gallery3.php
@@ -40,7 +40,7 @@ class Gallery3 {
$response = Gallery3_Helper::request(
"post", $url, null, array("user" => $user, "password" => $pass));
- return self::factory($url, $response->token, null);
+ return self::factory($url, $response, null);
}
/**
@@ -92,26 +92,12 @@ class Gallery3 {
}
/**
- * Create a new album. You must specify a name for the album, and call save() before the album
- * will be created in the remote Gallery 3.
+ * Create a new resource. You must call save() for it to be created in the remote Gallery 3.
*
* @return object Gallery3
*/
- public function create_album() {
- return Gallery3::factory(null, $this->token, $this)
- ->set_value("type", "album");
- }
-
- /**
- * Create a new photo. You must specify a name for the photo and use set_file() to attach an
- * image file. Finally, you must call save() before the photo will be created in the remote
- * Gallery 3.
- *
- * @return object Gallery3
- */
- public function create_photo() {
- return Gallery3::factory(null, $this->token, $this)
- ->set_value("type", "photo");
+ public function create() {
+ return Gallery3::factory(null, $this->token, $this);
}
/**
@@ -127,7 +113,11 @@ class Gallery3 {
"post", $this->parent->url, $this->token, $this->data, $this->file);
}
- return $this->load($response->url);
+ if (!empty($response->url)) {
+ $this->load($response->url);
+ }
+
+ return $this;
}
/**
diff --git a/client/example.php b/client/example.php
index f22709bc..e31903e3 100644
--- a/client/example.php
+++ b/client/example.php
@@ -9,29 +9,44 @@ if (file_exists("local_config.php")) {
include("local_config.php");
}
-// Connect to our Gallery
+print "Connect to $SITE_URL
";
$gallery3 = Gallery3::connect($SITE_URL, $USER, $PASSWORD);
-
$root = $gallery3->get("gallery");
+$tags = $gallery3->get("tags");
-// Create a new album
-$album = $root->create_album()
+print "Create a tag
";
+$tag = $tags->create()
+ ->set_value("name", "My Tag")
+ ->save();
+
+print "Create a new album
";
+$album = $root->create()
+ ->set_value("type", "album")
->set_value("name", "Sample Album")
->set_value("title", "This is my Sample Album")
->save();
-// Upload a new photo
-$photo = $album->create_photo()
+print "Upload a photo
";
+$photo = $album->create()
+ ->set_value("type", "photo")
->set_value("name", "Sample Photo")
->set_value("title", "Sample Photo")
->set_file("/tmp/foo.jpg")
->save();
-// Look up the album and modify it.
+print "Tag the photo
";
+$tag->create()
+ ->set_value("url", $photo->url)
+ ->save();
+
+print "Modify the album
";
$album = $root->get("Sample-Album")
->set_value("title", "This is my title")
->save();
// Now delete the album
+print "Delete the album
";
$album->delete();
+
+print "Done!
";
?>
\ No newline at end of file