Hi everyone,
my main purpose now is to upload photo(s) to picasaweb album from my own website (without surfing to google site) and retrieve back the image URL(s) by php coding. I found a sample from (http://www.ibm.com/developerworks/library/x-picasalbum/) which is using zend library, its works fine all the while but I met this error last day when i uploading a photo:-
Error: HTTP/1.1 400 Bad Request Expires: Thu, 19 Aug 2010 04:14:17 GMT Date: Thu, 19 Aug 2010 04:14:17 GMT Cache-control: private, max-age=0, must-revalidate Set-cookie: _rtok=ySBu81XkS7zR; Path=/; HttpOnly Set-cookie: S=photos_html=6f3_NANwyaefHBbxwRQKMQ; Domain=.google.com; Path=/; HttpOnly Content-type: text/html; charset=UTF-8 X-content-type-options: nosniff X-frame-options: SAMEORIGIN X-xss-protection: 1; mode=block Server: GSE Connection: close A title or Slug header is required
I had updated zend lib and I pretty sure that this coding is usable to upload picture(s). However, the other 2 coding provided from the website is still usable (listing photo,deleting photo in album).
Hereby, can anyone can help me to solve out this error? Or any other sample code I can refer to? Thanks for viewing :)
//my php code for photo upload
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Photos');
Zend_Loader::loadClass('Zend_Http_Client');
// connect to service
$svc = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$user = "xxx";
$pass = "xxx";
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $svc);
$gphoto = new Zend_Gdata_Photos($client);
// validate input
if (empty($_POST['title'])) {
die('ERROR: Missing title');
}
// sanitize input
$title = htmlentities($_POST['title']);
$tags = htmlentities($_POST['tags']);
// set album name
$albumName = "xxx";
// construct photo object
// save to server
try {
$photo = $gphoto->newPhotoEntry();
// set file
$file = $gphoto->newMediaFileSource($_FILES['photofile']['tmp_name']);
$file->setContentType("image/jpeg");
$photo->setMediaSource($file);
// set title
$photo->setSummary($gphoto->newSummary($title));
// set tags
$photo->mediaGroup = new Zend_Gdata_Media_Extension_MediaGroup();
$keywords = new Zend_Gdata_Media_Extension_MediaKeywords();
$keywords->setText($tags);
$photo->mediaGroup->keywords = $keywords;
// link to album
$album = $gphoto->newAlbumQuery();
$album->setUser($user);
$album->setAlbumName($albumName);
// save photo
$gphoto->insertPhotoEntry($photo, $album->getQueryUrl());
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getResponse();
}
echo 'Photo successfully added!';
}