13 messages in com.googlegroups.google-picasa-data-apiRe: inserting comments with PHP4
FromSent OnAttachments
voorhuid16 Apr 2008 11:18 
Jeff Fisher (Google)18 Apr 2008 13:25 
voorhuid19 Apr 2008 16:43 
Jochen Hartmann (Google)22 Apr 2008 06:26 
voorhuid22 Apr 2008 11:03 
Jeff Fisher (Google)23 Apr 2008 03:22 
voorhuid23 Apr 2008 13:13 
Jochen Hartmann (Google)24 Apr 2008 03:19 
voorhuid24 Apr 2008 04:47 
Jochen Hartmann (Google)24 Apr 2008 06:18 
voorhuid24 Apr 2008 08:08 
Jeff Fisher (Google)25 Apr 2008 03:25 
voorhuid25 Apr 2008 05:13 
Subject:Re: inserting comments with PHP4
From:voorhuid (voor@gmail.com)
Date:04/22/2008 11:03:56 AM
List:com.googlegroups.google-picasa-data-api

Jochem,

Tank you for your effort. I scanned the code you used, and the only difference I could find is that you are using the albumid i.s.o. albumname like I do. I tried to refer to the album-id as well this time, but still no success!

Could it be the session token I am using? I noticed that both the token and session token are different on each request. I would figure the request would return always the same token, as the same algorithm is used with the same input every time. On the other hand, if no valid token could be generated, one would assume google returns an error. I am really kinda stuck here. If you want my code for retrieving a session token, please let me know.

Mark

On Apr 22, 3:26 pm, "Jochen Hartmann (Google)" <api.@google.com> wrote:

Hi,

I was not able to replicate the error that you were getting. Running this on my development machine, which uses php 5.2 works perfectly. Here is my code:

function postItem($sessionToken) {

$itemsFeedURL = 'http://picasaweb.google.com/data/feed/api/user/ test.api.jhartmann/albumid/5192046855371220017/photoid/ 5192046932680631378';

$insertComment = "<entry xmlns='http://www.w3.org/2005/Atom'>" . "<content>This is what all the gentlemen are wearing this season.</content>" . "<category scheme=\"http://schemas.google.com/g/2005#kind\" " . "term=\"http://schemas.google.com/photos/2007#comment\"/></ entry>";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $itemsFeedURL); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: AuthSub token="' . $sessionToken . '"', 'Content-Type: application/atom+xml' )); curl_setopt($ch, CURLOPT_POSTFIELDS, $insertComment);

$result = curl_exec($ch); echo curl_error($ch); print $result;

}

And here is the comment entry that it produced:

http://picasaweb.google.com/test.api.jhartmann/Test#5192046932680631378

I ran this from a session based page that uses AuthSub authentication. More documentation is available at the link below:

http://code.google.com/apis/picasaweb/developers_guide_php.html#AuthSub

Cheers, - Jochen

On Apr 20, 1:44 am, voorhuid <voor@gmail.com> wrote:

Thank you for replying. The devkey came from some gdata example I found somewhere. I took it out and followed your suggestion on returning the curl error. Now I get this:

The requested URL returned error: 500

This really makes me feel like a newbie.. I must be missing something obvious. Here's the code I used:

function postItem($sessionToken) {

$itemsFeedURL = "http://picasaweb.google.com/data/feed/api/user/12345/ album/23456/photoid/5180987208362827106";

$insertComment = "<entry xmlns='http://www.w3.org/2005/Atom'> <content>This is what all the
gentlemen are wearing this season.</content> <category
scheme=\"http://schemas.google.com/g/2005#kind\" term=\"http://schemas.google.com/photos/2007#comment\"/> </entry>";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $itemsFeedURL); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: AuthSub token="' . $sessionToken . '"', 'Content-Type: application/atom+xml' )); curl_setopt($ch, CURLOPT_POSTFIELDS, $insertComment);

$result = curl_exec($ch); echo curl_error($ch); print $result;

}

On Apr 18, 10:25 pm, "Jeff Fisher (Google)" <api.@google.com> wrote:

Hi,

I'm not sure where you got the developer key from, Picasa Web Albums does not use one.

curl_exec() returns false on error. To get the error message you can do something like

echo curl_error($ch);

Cheers, -Jeff

On Apr 16, 11:18 am, voorhuid <voor@gmail.com> wrote:

Can't for the life of me figure out how to..

I am using PHP4 so I cannot use the Zend libraries. If someone here please could help me on my way. I browsed the (very limited) documentation and found some bits and pieces of code that I put together. This is what I came up with so far, but with no success:

(assume I already have the session token at this point)

function postItem($sessionToken) {

$developerKey = "ABQIAS3AsM5cF-m8CdphuQfT33aSF8ru17474hh7d1Pjlrg";

$itemsFeedURL = "http://picasaweb.google.com/data/feed/api/user/[my username]/album/[my album name]/photoid/[my photo id]";

$insertComment = "<entry xmlns='http://www.w3.org/2005/Atom'> <content>Test comment 1</content> <category
scheme=\"http://schemas.google.com/g/2005#kind\" term=\"http://schemas.google.com/photos/2007#comment\"/> </entry>"; $ch = curl_init(); /* Create a CURL handle. */

/* Set cURL options. */ curl_setopt($ch, CURLOPT_URL, $itemsFeedURL); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: AuthSub token="' . $sessionToken . '"', 'X-Google-Key: key=' . $developerKey, 'Content-Type: application/atom+xml' )); curl_setopt($ch, CURLOPT_POSTFIELDS, $insertComment);

$result = curl_exec($ch); /* Execute the HTTP request. */ curl_close($ch); /* Close the cURL handle. */

return $result;

}

After invoking this function nothing actually happens and returns 'false'. I've been trying to get my head around this for some time now, but really kinda stumbling in the dark here. Any help is greatly appreciated!