PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Creating Entries

The service has functions to create albums, photos, comments, and tags.

Creating An Album

The service supports creating a new album for an authenticated user:

<?php
$service 
Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client Zend_Gdata_ClientLogin::getHttpClient($user$pass$service);
$service = new Zend_Gdata_Photos($client);

$entry = new Zend_Gdata_Photos_AlbumEntry();
$entry->setTitle($service->newTitle("test album"));

$service->insertAlbumEntry($entry);

Creating A Photo

The service supports creating a new photo for an authenticated user:

<?php
$service 
Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client Zend_Gdata_ClientLogin::getHttpClient($user$pass$service);
$service = new Zend_Gdata_Photos($client);

// $photo is the name of a file uploaded via an HTML form

$fd $service->newMediaFileSource($photo["tmp_name"]);
$fd->setContentType($photo["type"]);

$entry = new Zend_Gdata_Photos_PhotoEntry();
$entry->setMediaSource($fd);
$entry->setTitle($service->newTitle($photo["name"]));

$albumQuery = new Zend_Gdata_Photos_AlbumQuery;
$albumQuery->setUser("sample.user");
$albumQuery->setAlbumId("1");

$albumEntry $service->getAlbumEntry($albumQuery);

$service->insertPhotoEntry($entry$albumEntry);

Creating A Comment

The service supports creating a new comment for a photo:

<?php
$service 
Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client Zend_Gdata_ClientLogin::getHttpClient($user$pass$service);
$service = new Zend_Gdata_Photos($client);

$entry = new Zend_Gdata_Photos_CommentEntry();
$entry->setTitle($service->newTitle("comment"));
$entry->setContent($service->newContent("comment"));

$photoQuery = new Zend_Gdata_Photos_PhotoQuery;
$photoQuery->setUser("sample.user");
$photoQuery->setAlbumId("1");
$photoQuery->setPhotoId("100");
$photoQuery->setType('entry');

$photoEntry $service->getPhotoEntry($photoQuery);

$service->insertCommentEntry($entry$photoEntry);

Creating A Tag

The service supports creating a new tag for a photo:

<?php
$service 
Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client Zend_Gdata_ClientLogin::getHttpClient($user$pass$service);
$service = new Zend_Gdata_Photos($client);

$entry = new Zend_Gdata_Photos_TagEntry();
$entry->setTitle($service->newTitle("tag"));

$photoQuery = new Zend_Gdata_Photos_PhotoQuery;
$photoQuery->setUser("sample.user");
$photoQuery->setAlbumId("1");
$photoQuery->setPhotoId("100");
$photoQuery->setType('entry');

$photoEntry $service->getPhotoEntry($photoQuery);

$service->insertTagEntry($entry$photoEntry);

Zend Framework