Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Thanked 0 Times in 0 Posts

    Picasa API Issues

    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

    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

    <!DOCTYPE html 
      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        <title>Adding photos to an album</title>
        body {
          font-family: Verdana;      
        li {
          border-bottom: solid black 1px;      
          margin: 10px; 
          padding: 2px; 
          width: auto;
          padding-bottom: 20px;
        h2 {
          color: red; 
          text-decoration: none;  
        span.attr {
          font-weight: bolder;  
        <h1>Add Photo</h1>
        <?php if (!isset($_POST['submit'])) { ?>
        <form method="post" action="<?php 
         echo htmlentities($_SERVER['PHP_SELF']); ?>" enctype="multipart/form-data">
          Title: <br/>
          <input name="title" type="text" size="25" /><p/>
          File to upload: <br/>
          <input name="photofile" type="file" /><p/>      
          Tags: <br/>
          <input name="tags" type="text" size="25" /><p/>
          <input name="submit" type="submit" value="Save" />
        } else {
          // load classes
    	  $clientLibraryPath = '/var/www/vhosts/sitename.com/httpdocs/standards/ZendGdata-1.10.0/library/';
    	  $oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . $clientLibraryPath);
          require_once 'Zend/Loader.php';
          // connect to service
          $svc = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
          $user = "userid@gmail.com";
          $pass = "secret";
          $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 = "France2008";
          // construct photo object
          // save to server      
          try {        
            $photo = $gphoto->newPhotoEntry();
            // set file
            $file = $gphoto->newMediaFileSource($_FILES['photofile']['tmp_name']);
            // set title
            // set tags
            $photo->mediaGroup = new Zend_Gdata_Media_Extension_MediaGroup();
            $keywords = new Zend_Gdata_Media_Extension_MediaKeywords();
            $photo->mediaGroup->keywords = $keywords;
            // link to album
            $album = $gphoto->newAlbumQuery();        
            // save photo
            $gphoto->insertPhotoEntry($photo, $album->getQueryUrl()); 
          } catch (Zend_Gdata_App_Exception $e) {
            echo "Error: " . $e->getResponse();
          echo 'Photo successfully added!';      

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,662 Times in 2,631 Posts
    How do you know that it fails at that step and not a previous step? I presume that you're not getting either the error for the catch or the successful notification, nor the ending body or html tag?

    If you have an ide capable of a debug, walk through all that code to ensure that it is the call to insertPhotoEntry causing the issue. Since there are no regular print calls inside the else block, you'll need to start adding some to see how far you get.
    First thing to do is enable you're error reporting:
    PHP Code:
    If there are any particular errors, it will indicate what and where. If no error occur, it will be a logic error, though I do not see anything blatent from what you have here. The only oddity that I can see is you're extension to the included path; did you change sitename.com to a valid one, or is that what it actually is inside the script? If this has not been changed, you're likely dying on the require_once call.

    I should mention I have no idea whatsoever what the Picasa album is. I presume its somehow related to what appears to be gmail, but I cannot be certain.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts