Upload image to picasaweb from our site(php) without goin to picasaweb site

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • edwincck712
    New Member
    • Aug 2010
    • 1

    #1

    Upload image to picasaweb from our site(php) without goin to picasaweb site

    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=ySBu81XkS 7zR; Path=/; HttpOnly Set-cookie: S=photos_html=6 f3_NANwyaefHBbx wRQKMQ; 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::lo adClass('Zend_G data');
    Zend_Loader::lo adClass('Zend_G data_ClientLogi n');
    Zend_Loader::lo adClass('Zend_G data_Photos');
    Zend_Loader::lo adClass('Zend_H ttp_Client');

    // connect to service
    $svc = Zend_Gdata_Phot os::AUTH_SERVIC E_NAME;
    $user = "xxx";
    $pass = "xxx";
    $client = Zend_Gdata_Clie ntLogin::getHtt pClient($user, $pass, $svc);
    $gphoto = new Zend_Gdata_Phot os($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->newMediaFileSo urce($_FILES['photofile']['tmp_name']);
    $file->setContentType ("image/jpeg");
    $photo->setMediaSource ($file);

    // set title
    $photo->setSummary($gp hoto->newSummary($ti tle));

    // set tags
    $photo->mediaGroup = new Zend_Gdata_Medi a_Extension_Med iaGroup();
    $keywords = new Zend_Gdata_Medi a_Extension_Med iaKeywords();
    $keywords->setText($tags) ;
    $photo->mediaGroup->keywords = $keywords;

    // link to album
    $album = $gphoto->newAlbumQuery( );
    $album->setUser($user) ;
    $album->setAlbumName($ albumName);

    // save photo
    $gphoto->insertPhotoEnt ry($photo, $album->getQueryUrl()) ;
    } catch (Zend_Gdata_App _Exception $e) {
    echo "Error: " . $e->getResponse( );
    }
    echo 'Photo successfully added!';
    }
Working...