By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,043 Members | 1,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,043 IT Pros & Developers. It's quick & easy.

Picasa API Issues

100+
P: 162
Im trying to do a basic upload to my Picasa album. I've tried the example in the documentation and one found on another site. Both fail with no error at the last step, a call to

Expand|Select|Wrap|Line Numbers
  1. insertPhotoEntry()
Zend is set up correctly and pathing is correct. I know this because the test script they provide comes back all tests ok.

Any ideas why? Below is the test script

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html 
  2.   PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3.   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  5.   <head>
  6.     <title>Adding photos to an album</title>
  7.     <style>
  8.     body {
  9.       font-family: Verdana;      
  10.     }
  11.     li {
  12.       border-bottom: solid black 1px;      
  13.       margin: 10px; 
  14.       padding: 2px; 
  15.       width: auto;
  16.       padding-bottom: 20px;
  17.     }
  18.     h2 {
  19.       color: red; 
  20.       text-decoration: none;  
  21.     }
  22.     span.attr {
  23.       font-weight: bolder;  
  24.     }
  25.     </style>    
  26.   </head>
  27.   <body>
  28.     <h1>Add Photo</h1>
  29.     <?php if (!isset($_POST['submit'])) { ?>
  30.     <form method="post" action="<?php 
  31.      echo htmlentities($_SERVER['PHP_SELF']); ?>" enctype="multipart/form-data">
  32.       Title: <br/>
  33.       <input name="title" type="text" size="25" /><p/>
  34.       File to upload: <br/>
  35.       <input name="photofile" type="file" /><p/>      
  36.       Tags: <br/>
  37.       <input name="tags" type="text" size="25" /><p/>
  38.       <input name="submit" type="submit" value="Save" />
  39.     </form>
  40.     <?php
  41.     } else {
  42.       // load classes
  43.       $clientLibraryPath = '/var/www/vhosts/sitename.com/httpdocs/standards/ZendGdata-1.10.0/library/';
  44.       $oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . $clientLibraryPath);
  45.       require_once 'Zend/Loader.php';
  46.       Zend_Loader::loadClass('Zend_Gdata');
  47.       Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
  48.       Zend_Loader::loadClass('Zend_Gdata_Photos');
  49.       Zend_Loader::loadClass('Zend_Http_Client');
  50.  
  51.       // connect to service
  52.       $svc = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
  53.       $user = "userid@gmail.com";
  54.       $pass = "secret";
  55.       $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $svc);
  56.       $gphoto = new Zend_Gdata_Photos($client);
  57.  
  58.       // validate input
  59.       if (empty($_POST['title'])) {
  60.         die('ERROR: Missing title');
  61.       } 
  62.  
  63.       // sanitize input
  64.       $title = htmlentities($_POST['title']);
  65.       $tags = htmlentities($_POST['tags']);
  66.  
  67.       // set album name
  68.       $albumName = "France2008";
  69.  
  70.       // construct photo object
  71.       // save to server      
  72.       try {        
  73.         $photo = $gphoto->newPhotoEntry();
  74.  
  75.         // set file
  76.         $file = $gphoto->newMediaFileSource($_FILES['photofile']['tmp_name']);
  77.         $file->setContentType("image/jpeg");
  78.         $photo->setMediaSource($file);
  79.  
  80.         // set title
  81.         $photo->setSummary($gphoto->newSummary($title));
  82.  
  83.         // set tags
  84.         $photo->mediaGroup = new Zend_Gdata_Media_Extension_MediaGroup();
  85.         $keywords = new Zend_Gdata_Media_Extension_MediaKeywords();
  86.         $keywords->setText($tags);
  87.         $photo->mediaGroup->keywords = $keywords;
  88.  
  89.         // link to album
  90.         $album = $gphoto->newAlbumQuery();        
  91.         $album->setUser($user);
  92.         $album->setAlbumName($albumName);
  93.  
  94.         // save photo
  95.         $gphoto->insertPhotoEntry($photo, $album->getQueryUrl()); 
  96.       } catch (Zend_Gdata_App_Exception $e) {
  97.         echo "Error: " . $e->getResponse();
  98.       }
  99.       echo 'Photo successfully added!';      
  100.     }
  101.     ?>
  102.   </body>
  103. </html>    
  104.  
Mar 11 '10 #1
Share this Question
Share on Google+
1 Reply


Markus
Expert 5K+
P: 6,050
You'd be better off asking on the developers group/list.
Mar 11 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.