1
0
This repository has been archived on 2021-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
gallery3-contrib/client/example.php
Bharat Mediratta 96f9aa482d Gallery3::create_xxx() methods are now just create(). We don't
differentiate between types of resources at this level, it's not
necessary.

Add example code for dealing with tags.
2010-01-04 21:49:40 -08:00

52 lines
1.1 KiB
PHP

<?
include("Gallery3.php");
$SITE_URL = "http://example.com/gallery3";
$USER = "admin";
$PASSWORD = "admin";
if (file_exists("local_config.php")) {
include("local_config.php");
}
print "Connect to $SITE_URL <br/>";
$gallery3 = Gallery3::connect($SITE_URL, $USER, $PASSWORD);
$root = $gallery3->get("gallery");
$tags = $gallery3->get("tags");
print "Create a tag <br/>";
$tag = $tags->create()
->set_value("name", "My Tag")
->save();
print "Create a new album <br/>";
$album = $root->create()
->set_value("type", "album")
->set_value("name", "Sample Album")
->set_value("title", "This is my Sample Album")
->save();
print "Upload a photo <br/>";
$photo = $album->create()
->set_value("type", "photo")
->set_value("name", "Sample Photo")
->set_value("title", "Sample Photo")
->set_file("/tmp/foo.jpg")
->save();
print "Tag the photo <br/>";
$tag->create()
->set_value("url", $photo->url)
->save();
print "Modify the album <br/>";
$album = $root->get("Sample-Album")
->set_value("title", "This is my title")
->save();
// Now delete the album
print "Delete the album <br/>";
$album->delete();
print "Done! <br/>";
?>