Base Feed upload automatically OR post few articles at once

7 messages Options
Embed this post
Permalink
patrick_try

Base Feed upload automatically OR post few articles at once

Reply Threaded More More options
Print post
Permalink
My question is simple: How is it possible to post some articles to google base at once?

When I think of a feed that works correctly with a manuel upload and want to make it automatically with the following code, it shows an error without any reason/explanation:
---------------------------
function postItem() {
  global $itemsFeedURL;

  $client = Zend_Gdata_AuthSub::getHttpClient($_POST['token']);
  $gdata = new Zend_Gdata($client);
 
$filename1 = "datenfeedkonstrukt.xml";
$handle1 = fopen ($filename1, "r");

$response = $gdata->post(fread ($handle1, filesize ($filename1)), $itemsFeedURL);

  return $response;
}





When I go another way and fill the createOrEditEntry-function with ARRAY-entries it seems to resolve nothing. For example with the array $ga_beschr (2 articles):
--------------------------
...
$newEntry->content  = $ga_beschr;
...
--------------------------
it effects 2 google base entries, but both have NO CONTENT, if it see's that there are 2 articles, but he cannot read the array.

Does anyone of you has an working idea for it? The first way would be easier, 'cause you can see and change the whole file... - but any help would help. ^^

THX in advance,
Ryan Boyd-3

Re: Base Feed upload automatically OR post few articles at once

Reply Threaded More More options
Print post
Permalink
Hi Patrick,

Can you show us example content from the file?  Is the data in the file formatted as a Google Data batch request?

Cheers,
-Ryan


On Fri, Jun 20, 2008 at 4:16 PM, patrick_try <[hidden email]> wrote:

My question is simple: How is it possible to post some articles to google
base at once?

When I think of a feed that works correctly with a manuel upload and want to
make it automatically with the following code, it shows an error without any
reason/explanation:
---------------------------
function postItem() {
 global $itemsFeedURL;

 $client = Zend_Gdata_AuthSub::getHttpClient($_POST['token']);
 $gdata = new Zend_Gdata($client);

$filename1 = "datenfeedkonstrukt.xml";
$handle1 = fopen ($filename1, "r");

$response = $gdata->post(fread ($handle1, filesize ($filename1)),
$itemsFeedURL);

 return $response;
}
--------------------------

When I go another way and fill the createOrEditEntry-function with
ARRAY-entries it seems to resolve nothing. For example with the array
$ga_beschr (2 articles):
--------------------------
...
$newEntry->content  = $ga_beschr;
...
--------------------------
it effects 2 google base entries, but both have NO CONTENT, if it see's that
there are 2 articles, but he cannot read the array.

Does anyone of you has an working idea for it? The first way would be
easier, 'cause you can see and change the whole file... - but any help would
help. ^^

THX in advance,

--
View this message in context: http://www.nabble.com/Base-Feed-upload-automatically-OR-post-few-articles-at-once-tp18039002p18039002.html
Sent from the Zend gdata mailing list archive at Nabble.com.


patrick_try

Re: Base Feed upload automatically OR post few articles at once

Reply Threaded More More options
Print post
Permalink
Hi Ryan,

if I use the Google-Page "Google Base data API - Demo" and try out the API there with a batch run, it works.

The data (respectively the file datenfeedkonstrukt.xml) is:
---------------------------------------------
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'
      xmlns:g='http://base.google.com/ns/1.0'
      xmlns:batch='http://schemas.google.com/gdata/batch'>
  <entry>
    <batch:id>itemA</batch:id>
    <batch:operation type='insert'/>
  <author>
    <name>default Shopping</name>
  </author>
  <category scheme="http://base.google.com/categories/itemtypes" term="products"/>
<link rel="alternate" type="text/html" href="http://kaatoo.at"/>
  <title type="text">Shirt, Flashlights, weiter Ausschnitt</title>
  <content type="html">Knallig, pastellig oder einfach schwarz: Gut sind sie alle! Grosszuegiger Ausschnitt. Gerollte Saeume an Ausschnitt und Aermeln. Laenge ca. 56 cm. Sehr figurbetonte Form. 70 % Baumwolle, 30 % Polyamid.</content>
<g:bild_url>http://www.google.de/intl/de_de/images/logo.gif</g:bild_url>
<g:preis>19.99</g:preis>
<g:target_country>DE</g:target_country>
<g:item_language>DE</g:item_language>
<language>de-DE</language>
<g:item_type type="text">Produkte</g:item_type>
</entry>

  <entry>
    <batch:id>itemB</batch:id>
    <batch:operation type='insert'/>
  <author>
    <name>default Shopping</name>
  </author>
  <category scheme="http://base.google.com/categories/itemtypes" term="products"/>
<link rel="alternate" type="text/html" href="http://kaatoo.at"/>
  <title type="text">Shirt2222, Flashlights, weiter Ausschnitt</title>
  <content type="html">Knallig1322222, pastellig oder einfach schwarz: Gut sind sie alle! Grosszuegiger Ausschnitt. Gerollte Saeume an Ausschnitt und Aermeln. Laenge ca. 56 cm. Sehr figurbetonte Form. 70 % Baumwolle, 30 % Polyamid.</content>
<g:bild_url>http://www.google.de/intl/de_de/images/logo.gif</g:bild_url>
<g:preis>29.99</g:preis>
<g:target_country>DE</g:target_country>
<g:item_language>DE</g:item_language>
<language>de-DE</language>
<g:item_type type="text">Produkte</g:item_type>
</entry>
</feed>
---------------------------------------------
Only the image works not correctly with that code, but the API is filled and the entry is in gBase. :-)
But exact this file (or maybe in another way) I want to post automatically with the zend-code (previous message of me) but my feedback on the test-page shows every time:
"Failed: Post to Google failed. Reason: " and the entry isn't in gBase .

THX 4 any help



Ryan Boyd-3 wrote:
Hi Patrick,

Can you show us example content from the file?  Is the data in the file
formatted as a Google Data batch request?

Cheers,
-Ryan


On Fri, Jun 20, 2008 at 4:16 PM, patrick_try <try.out@gmx.de> wrote:

>
> My question is simple: How is it possible to post some articles to google
> base at once?
>
> When I think of a feed that works correctly with a manuel upload and want
> to
> make it automatically with the following code, it shows an error without
> any
> reason/explanation:
> ---------------------------
> function postItem() {
>  global $itemsFeedURL;
>
>  $client = Zend_Gdata_AuthSub::getHttpClient($_POST['token']);
>  $gdata = new Zend_Gdata($client);
>
> $filename1 = "datenfeedkonstrukt.xml";
> $handle1 = fopen ($filename1, "r");
>
> $response = $gdata->post(fread ($handle1, filesize ($filename1)),
> $itemsFeedURL);
>
>  return $response;
> }
> --------------------------
>
> When I go another way and fill the createOrEditEntry-function with
> ARRAY-entries it seems to resolve nothing. For example with the array
> $ga_beschr (2 articles):
> --------------------------
> ...
> $newEntry->content  = $ga_beschr;
> ...
> --------------------------
> it effects 2 google base entries, but both have NO CONTENT, if it see's
> that
> there are 2 articles, but he cannot read the array.
>
> Does anyone of you has an working idea for it? The first way would be
> easier, 'cause you can see and change the whole file... - but any help
> would
> help. ^^
>
> THX in advance,
>
> --
> View this message in context:
> http://www.nabble.com/Base-Feed-upload-automatically-OR-post-few-articles-at-once-tp18039002p18039002.html
> Sent from the Zend gdata mailing list archive at Nabble.com.
>
>
Ryan Boyd-3

Re: Base Feed upload automatically OR post few articles at once

Reply Threaded More More options
Print post
Permalink
Hi Patrick,

I think you may just be using the regular items URL (and not the batch URL) when doing the post?  

This code worked fine for me:
<?php
require_once 'Zend/Gdata/AuthSub.php';
require_once 'Zend/Gdata.php';

$token = 'CJ6F....8B';
$client = Zend_Gdata_AuthSub::getHttpClient($token);
$gdata = new Zend_Gdata($client);

$filename1 = "data.xml";
$handle1 = fopen ($filename1, "r");

$response = $gdata->post(fread ($handle1, filesize ($filename1)), $itemsFeedURL);

var_dump($response);
?>

Cheers,
-Ryan



On Sat, Jun 21, 2008 at 1:20 AM, patrick_try <[hidden email]> wrote:

Hi Ryan,

if I use the Google-Page "Google Base data API - Demo" and try out the API
there with a batch run, it works.

The data (respectively the file datenfeedkonstrukt.xml) is:
---------------------------------------------
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'
     xmlns:g='http://base.google.com/ns/1.0'
     xmlns:batch='http://schemas.google.com/gdata/batch'>
 <entry>
   <batch:id>itemA</batch:id>
   <batch:operation type='insert'/>
 <author>
   <name>default Shopping</name>
 </author>
 <category scheme="http://base.google.com/categories/itemtypes"
term="products"/>
<link rel="alternate" type="text/html" href="http://kaatoo.at"/>
 <title type="text">Shirt, Flashlights, weiter Ausschnitt</title>
 <content type="html">Knallig, pastellig oder einfach schwarz: Gut sind sie
alle! Grosszuegiger Ausschnitt. Gerollte Saeume an Ausschnitt und Aermeln.
Laenge ca. 56 cm. Sehr figurbetonte Form. 70 % Baumwolle, 30 %
Polyamid.</content>
<g:bild_url>http://www.google.de/intl/de_de/images/logo.gif</g:bild_url>
<g:preis>19.99</g:preis>
<g:target_country>DE</g:target_country>
<g:item_language>DE</g:item_language>
<language>de-DE</language>
<g:item_type type="text">Produkte</g:item_type>
</entry>

 <entry>
   <batch:id>itemB</batch:id>
   <batch:operation type='insert'/>
 <author>
   <name>default Shopping</name>
 </author>
 <category scheme="http://base.google.com/categories/itemtypes"
term="products"/>
<link rel="alternate" type="text/html" href="http://kaatoo.at"/>
 <title type="text">Shirt2222, Flashlights, weiter Ausschnitt</title>
 <content type="html">Knallig1322222, pastellig oder einfach schwarz: Gut
sind sie alle! Grosszuegiger Ausschnitt. Gerollte Saeume an Ausschnitt und
Aermeln. Laenge ca. 56 cm. Sehr figurbetonte Form. 70 % Baumwolle, 30 %
Polyamid.</content>
<g:bild_url>http://www.google.de/intl/de_de/images/logo.gif</g:bild_url>
<g:preis>29.99</g:preis>
<g:target_country>DE</g:target_country>
<g:item_language>DE</g:item_language>
<language>de-DE</language>
<g:item_type type="text">Produkte</g:item_type>
</entry>
</feed>
---------------------------------------------
Only the image works not correctly with that code, but the API is filled and
the entry is in gBase. :-)
But exact this file (or maybe in another way) I want to post automatically
with the zend-code (previous message of me) but my feedback on the test-page
shows every time:
"Failed: Post to Google failed. Reason: " and the entry isn't in gBase %-|.

THX 4 any help




Ryan Boyd-3 wrote:
>
> Hi Patrick,
>
> Can you show us example content from the file?  Is the data in the file
> formatted as a Google Data batch request?
>
> Cheers,
> -Ryan
>
>
> On Fri, Jun 20, 2008 at 4:16 PM, patrick_try <[hidden email]> wrote:
>
>>
>> My question is simple: How is it possible to post some articles to google
>> base at once?
>>
>> When I think of a feed that works correctly with a manuel upload and want
>> to
>> make it automatically with the following code, it shows an error without
>> any
>> reason/explanation:
>> ---------------------------
>> function postItem() {
>>  global $itemsFeedURL;
>>
>>  $client = Zend_Gdata_AuthSub::getHttpClient($_POST['token']);
>>  $gdata = new Zend_Gdata($client);
>>
>> $filename1 = "datenfeedkonstrukt.xml";
>> $handle1 = fopen ($filename1, "r");
>>
>> $response = $gdata->post(fread ($handle1, filesize ($filename1)),
>> $itemsFeedURL);
>>
>>  return $response;
>> }
>> --------------------------
>>
>> When I go another way and fill the createOrEditEntry-function with
>> ARRAY-entries it seems to resolve nothing. For example with the array
>> $ga_beschr (2 articles):
>> --------------------------
>> ...
>> $newEntry->content  = $ga_beschr;
>> ...
>> --------------------------
>> it effects 2 google base entries, but both have NO CONTENT, if it see's
>> that
>> there are 2 articles, but he cannot read the array.
>>
>> Does anyone of you has an working idea for it? The first way would be
>> easier, 'cause you can see and change the whole file... - but any help
>> would
>> help. ^^
>>
>> THX in advance,
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Base-Feed-upload-automatically-OR-post-few-articles-at-once-tp18039002p18039002.html
>> Sent from the Zend gdata mailing list archive at Nabble.com.
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Base-Feed-upload-automatically-OR-post-few-articles-at-once-tp18039002p18042049.html
Sent from the Zend gdata mailing list archive at Nabble.com.


patrick_try

Re: Base Feed upload automatically OR post few articles at once

Reply Threaded More More options
Print post
Permalink
THX. That could be my mistake, but if I change the parameter I always get this massage:
----------------------------------------------
object(Zend_Http_Response)#14 (5) { ["version:protected"]=>  string(3) "1.1" ["code:protected"]=>  int(200) ["message:protected"]=>  string(2) "OK" ["headers:protected"]=>  array(8) { ["Content-type"]=>  string(35) "application/atom+xml; charset=UTF-8" ["Gdata-version"]=>  string(3) "1.0" ["Date"]=>  string(29) "Mon, 23 Jun 2008 13:08:47 GMT" ["Expires"]=>  string(29) "Mon, 23 Jun 2008 13:08:46 GMT" ["Cache-control"]=>  string(18) "private, max-age=0" ["Content-length"]=>  string(3) "857" ["Server"]=>  string(7) "GFE/1.3" ["Connection"]=>  string(5) "Close" } ["body:protected"]=>  string(857) "http://www.google.com/base/feeds/items2008-06-23T13:08:46.988ZBatch Feed" }
----------------------------------------------
Any ideas?
Ryan Boyd-3

Re: Base Feed upload automatically OR post few articles at once

Reply Threaded More More options
Print post
Permalink


On Mon, Jun 23, 2008 at 6:10 AM, patrick_try <[hidden email]> wrote:

THX. That could be my mistake, but if I change the parameter I always get
this massage:

Sorry - I don't think I'm understanding correctly.

What parameter are you changing?  I'm not sure how the e-mail client is messing with the XML in the response->body, but the response you printed out is a 200 response, which generally indicates success, though you may wish to look at the success of each element in the batch.

One thing you can do in the recent versions of the Zend_Gdata code, if you're not using a proxy server, is to log the requests to a file.  Here's how to do that:
$gdata->enableRequestDebugLogging('/tmp/gp_requests.log');

This will allow you to see the full raw HTTP request and response.  If you do post that to the list, please remember to remove the Authorization data (the AuthSub token).

Cheers,
-Ryan

 

----------------------------------------------
object(Zend_Http_Response)#14 (5) { ["version:protected"]=>  string(3) "1.1"
["code:protected"]=>  int(200) ["message:protected"]=>  string(2) "OK"
["headers:protected"]=>  array(8) { ["Content-type"]=>  string(35)
"application/atom+xml; charset=UTF-8" ["Gdata-version"]=>  string(3) "1.0"
["Date"]=>  string(29) "Mon, 23 Jun 2008 13:08:47 GMT" ["Expires"]=>
string(29) "Mon, 23 Jun 2008 13:08:46 GMT" ["Cache-control"]=>  string(18)
"private, max-age=0" ["Content-length"]=>  string(3) "857" ["Server"]=>
string(7) "GFE/1.3" ["Connection"]=>  string(5) "Close" }
["body:protected"]=>  string(857)
"http://www.google.com/base/feeds/items2008-06-23T13:08:46.988ZBatch Feed" }
----------------------------------------------
Any ideas?
--
View this message in context: http://www.nabble.com/Base-Feed-upload-automatically-OR-post-few-articles-at-once-tp18039002p18067225.html
Sent from the Zend gdata mailing list archive at Nabble.com.


patrick_try

Re: Base Feed upload automatically OR post few articles at once

Reply Threaded More More options
Print post
Permalink
THX RYAN! I tried and tried and then I kicked all the lines of Zend except this automatic-post-lines off and it works. Maybe some trashlines...
In this way I can use a generate XML-File to upload and changes all in the file for the API!

THX A LOT 4 YOUR HELP & PATIENCE!!! - Ryan you're the best!

Many greetings from germany!!!



Ryan Boyd-3 wrote:
On Mon, Jun 23, 2008 at 6:10 AM, patrick_try <try.out@gmx.de> wrote:

>
> THX. That could be my mistake, but if I change the parameter I always get
> this massage:


Sorry - I don't think I'm understanding correctly.

What parameter are you changing?  I'm not sure how the e-mail client is
messing with the XML in the response->body, but the response you printed out
is a 200 response, which generally indicates success, though you may wish to
look at the success of each element in the batch.

One thing you can do in the recent versions of the Zend_Gdata code, if
you're not using a proxy server, is to log the requests to a file.  Here's
how to do that:

$gdata->enableRequestDebugLogging('/tmp/gp_requests.log');


This will allow you to see the full raw HTTP request and response.  If you
do post that to the list, please remember to remove the Authorization data
(the AuthSub token).

Cheers,
-Ryan



>
> ----------------------------------------------
> object(Zend_Http_Response)#14 (5) { ["version:protected"]=>  string(3)
> "1.1"
> ["code:protected"]=>  int(200) ["message:protected"]=>  string(2) "OK"
> ["headers:protected"]=>  array(8) { ["Content-type"]=>  string(35)
> "application/atom+xml; charset=UTF-8" ["Gdata-version"]=>  string(3) "1.0"
> ["Date"]=>  string(29) "Mon, 23 Jun 2008 13:08:47 GMT" ["Expires"]=>
> string(29) "Mon, 23 Jun 2008 13:08:46 GMT" ["Cache-control"]=>  string(18)
> "private, max-age=0" ["Content-length"]=>  string(3) "857" ["Server"]=>
> string(7) "GFE/1.3" ["Connection"]=>  string(5) "Close" }
> ["body:protected"]=>  string(857)
> "http://www.google.com/base/feeds/items2008-06-23T13:08:46.988ZBatch Feed"
> }
> ----------------------------------------------
> Any ideas?
> --
> View this message in context:
> http://www.nabble.com/Base-Feed-upload-automatically-OR-post-few-articles-at-once-tp18039002p18067225.html
> Sent from the Zend gdata mailing list archive at Nabble.com.
>
>