If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Picasa API Issues

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-11-10, 05:19
cesarcesar cesarcesar is offline
Registered User
 
Join Date: Mar 2008
Posts: 55
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

Code:
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

Code:
<!DOCTYPE html 
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>Adding photos to an album</title>
    <style>
    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;  
    }
    </style>    
  </head>
  <body>
    <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" />
    </form>
    <?php
    } 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';
      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 = "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']);
        $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!';      
    }
    ?>
  </body>
</html>
Reply With Quote
  #2 (permalink)  
Old 03-11-10, 19:28
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,246
and the specific database problem you are having is?
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On