Hi Every one
i am getting errors while trying to run Google
base none of my product is getting uploaded ,i am getting following
errors .
[error] product_id:1 - [exception 'Zend_Gdata_App_HttpException' with
message 'Expected response code 200, got 400' in /var/www/
acropolis_source_code/ZendFramework-1.5.0/library/Zend/Gdata/App.php:
468 Stack trace: #0 /var/www/acropolis_source_code/ZendFramework-1.5.0/
library/Zend/Gdata/App.php(663): Zend_Gdata_App->post(Object
(Zend_Gdata_Gbase_ItemEntry), 'http://www.goog...') #1 /var/www/
acropolis_source_code/ZendFramework-1.5.0/library/Zend/Gdata/Gbase.php
(153): Zend_Gdata_App->insertEntry(Object(Zend_Gdata_Gbase_ItemEntry),
'http://www.goog...', 'Zend_Gdata_Gbas...') #2 /var/www/
acropolis_source_code_03_17_2009/admin/products-
googlebase_babycarriers.php(154): Zend_Gdata_Gbase->insertGbaseItem
(Object(Zend_Gdata_Gbase_ItemEntry), NULL) #3 /var/www/
acropolis_source_code_03_17_2009/admin/products-
googlebase_babycarriers.php(26): processPageLoad() #4 /var/www/vhosts/
babycarriersdirect.com/httpdocs/admin/index.php(49): require('/var/www/
acropo...') #5 {main}]
[error] product_id:2 - [exception 'Zend_Gdata_App_HttpException' with
message 'Expected response code 200, got 400' in /var/www/
acropolis_source_code/ZendFramework-1.5.0/library/Zend/Gdata/App.php:
468 Stack trace: #0 /var/www/acropolis_source_code/ZendFramework-1.5.0/
library/Zend/Gdata/App.php(663): Zend_Gdata_App->post(Object
(Zend_Gdata_Gbase_ItemEntry), 'http://www.goog...') #1 /var/www/
acropolis_source_code/ZendFramework-1.5.0/library/Zend/Gdata/Gbase.php
(153): Zend_Gdata_App->insertEntry(Object(Zend_Gdata_Gbase_ItemEntry),
'http://www.goog...', 'Zend_Gdata_Gbas...') #2 /var/www/
acropolis_source_code_03_17_2009/admin/products-
googlebase_babycarriers.php(154): Zend_Gdata_Gbase->insertGbaseItem
(Object(Zend_Gdata_Gbase_ItemEntry), NULL) #3 /var/www/
acropolis_source_code_03_17_2009/admin/products-
googlebase_babycarriers.php(26): processPageLoad() #4 /var/www/vhosts/
babycarriersdirect.com/httpdocs/admin/index.php(49): require('/var/www/
acropo...') #5 {main}]
......
.........
........... and so on
[error] product_id:227 - [exception 'Zend_Gdata_App_HttpException'
with message 'Expected response code 200, got 400' in /var/www/
acropolis_source_code/ZendFramework-1.5.0/library/Zend/Gdata/App.php:
468 Stack trace: #0 /var/www/acropolis_source_code/ZendFramework-1.5.0/
library/Zend/Gdata/App.php(663): Zend_Gdata_App->post(Object
(Zend_Gdata_Gbase_ItemEntry), 'http://www.goog...') #1 /var/www/
acropolis_source_code/ZendFramework-1.5.0/library/Zend/Gdata/Gbase.php
(153): Zend_Gdata_App->insertEntry(Object(Zend_Gdata_Gbase_ItemEntry),
'http://www.goog...', 'Zend_Gdata_Gbas...') #2 /var/www/
acropolis_source_code_03_17_2009/admin/products-
googlebase_babycarriers.php(154): Zend_Gdata_Gbase->insertGbaseItem
(Object(Zend_Gdata_Gbase_ItemEntry), NULL) #3 /var/www/
acropolis_source_code_03_17_2009/admin/products-
googlebase_babycarriers.php(26): processPageLoad() #4 /var/www/vhosts/
babycarriersdirect.com/httpdocs/admin/index.php(49): require('/var/www/
acropo...') #5 {main}]
0 successfully uploaded. 128 errors.
MY CODE IS :
processPageLoad();
function processPageLoad()
{
$query = "SELECT google_email,google_password,website_URL,extension
FROM settings";
$rs = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($rs,MYSQL_ASSOC)){
$email = $row['google_email'];
$passwd = $row['google_password'];
$website_URL = $row['website_URL'];
$domain = str_replace('http://','',$website_URL);
$domain = str_replace('www.','',$domain);
$domain = str_replace('/','',$domain);
$ext = $row['extension'];
}
global $_SESSION, $_GET;
$num_items = 0;
startHTML();
$service = Zend_Gdata_Gbase::AUTH_SERVICE_NAME;
try {
$client = Zend_Gdata_ClientLogin::getHttpClient($email, $passwd,
$service);
} catch (Zend_Gdata_App_CaptchaRequiredException $cre) {
echo 'URL of CAPTCHA image: ' . $cre->getCaptchaUrl() . "\n";
echo 'Token ID: ' . $cre->getCaptchaToken() . "\n";
exit;
} catch (Zend_Gdata_App_AuthException $ae) {
echo 'Problem authenticating: ' . $ae->exception() . "\n";
exit;
}
$query = "SELECT
p.productname,p.long_desc,p.sale_price,p.weight,p.SKU,p.UPC,p.product_ID,p.page_URL,p.lg_image,p.num_in_stock,p.active_stock,m.manufacturer_name,p.product_type
FROM products p INNER JOIN manufacturers m on p.manufacturer_ID =
m.manufacturer_ID WHERE upc != ''";
$rs = mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($rs,MYSQL_ASSOC)){
$service = new Zend_Gdata_Gbase($client);
$newEntry = $service->newItemEntry();
// Add title
$newEntry->title =
$service->newTitle(trim($row['productname']));
// Add some content
$content = strip_tags(nl2br($row['long_desc']));
$newEntry->content = $service->newContent($content);
$newEntry->content->type = 'text';
// Define product type
$itemType = "Products";
$newEntry->itemType = $itemType;
$newEntry->itemType->type = 'text';
// Add item-specific attributes
$newEntry->addGbaseAttribute('product_type',
$row['product_type'],
'text');
$newEntry->addGbaseAttribute('price', $row['sale_price'].' USD',
'floatUnit');
$newEntry->addGbaseAttribute('brand', $row['manufacturer_name'],
'text');
$newEntry->addGbaseAttribute('weight', $row['weight'].' lbs',
'numberUnit');
$newEntry->addGbaseAttribute('mpn', $row['SKU'], 'text');
$newEntry->addGbaseAttribute('condition', 'New', 'text');
$newEntry->addGbaseAttribute('UPC', $row['UPC'], 'text');
$newEntry->addGbaseAttribute('id', $row['product_ID'], 'text');
if ($row['active_stock']==1&&$row['num_in_stock']>0){
$newEntry->addGbaseAttribute('quantity',
($row['num_in_stock']+5),
'int');
} else {
$newEntry->addGbaseAttribute('quantity', 5, 'int');
}
/* custom attributes */
$query = "SELECT
cf.fieldtype,cv.customvalue_name,cf.customfield_name FROM customvalues
cv INNER JOIN productscustomvalues pcv ON pcv.customvalue_ID =
cv.customvalue_ID INNER JOIN customfields cf ON cf.customfield_ID =
cv.customfield_ID WHERE pcv.product_ID = ".$row['product_ID'];
$rs_cf = mysql_query($query) or die(mysql_error());
while($row_cf = mysql_fetch_array($rs_cf,MYSQL_ASSOC)){
switch($row_cf['fieldtype']){
case 'binary':
$fieldvalue =
strip_tags(nl2br($row_cf['customvalue_name']));
if(trim($fieldvalue)==0){
$fieldvalue = "No";
} elseif(trim($fieldvalue)==1){
$fieldvalue = "Yes";
}
$fieldname = str_replace('
','_',$row_cf['customfield_name']);
break;
case 'length':
$fieldvalue =
$row_cf['customvalue_name'];
$fieldname = str_replace('
','_',$row_cf['customfield_name']);
break;
case 'longstring':
//check to see if there is a list
inside the string.
$i=0;
preg_match_all('/\<li\>(.*?)\<\/li\>/s', $row_cf
['customvalue_name'], $matches);
foreach($matches[1] as $match){
$i++;
$newEntry->addGbaseAttribute('feature', strip_tags(nl2br
($match)), 'text');
}
if ($i==0){
$fieldvalue =
strip_tags(nl2br($row_cf['customvalue_name']));
$fieldname = str_replace('
','_',$row_cf['customfield_name']);
}
break;
default:
$fieldvalue =
strip_tags(nl2br($row_cf['customvalue_name']));
$fieldname = str_replace('
','_',$row_cf['customfield_name']);
break;
}
$newEntry->addGbaseAttribute($fieldname, $fieldvalue,
'text');
}
/*$newLink = new Zend_Gdata_App_Extension_Link();
$newLink->setHref('http://www.strollersdirect.com/'.$row
['page_URL'].'.htm');
$debug .=
'$newLink->setHref(\'http://www.strollersdirect.com/\''.
$row['page_URL'].'\'.htm\');';
$newLink->setRel('alternate');
$newLink->setType('text/html');
$linkArray = $newEntry->getLink();
$linkArray[] = $newLink;
$newEntry->setLink($linkArray);*/
$link = $service->newLink($website_URL.$row['page_URL'].$ext);
$link->type = 'text/html';
$link->rel = 'alternate';
$newEntry->link = array($link);
// Post the item
try {
$createdEntry = $service->insertGbaseItem($newEntry,
$dryRun);
$entryLink = $createdEntry->id;
/*
now time to post the image in the most
complicated way possible
(and also make this script take a lot longer to execute)
thanks google! can't wait till you take over
the world...
P.S. It used to be this easy:
$newEntry->addGbaseAttribute('image_link',
'http://
www.strollersdirect.com/images/lg_image/'.$row['lg_image'], 'url');
*/
$mediaLinkHref =
str_replace('http://www.google.com/base/feeds/
items/','http://base.google.com/base/feeds/items/',$entryLink).'/
media/';
$product_ID = $row['product_ID'];
$mediaFileSource =
$service->newMediaFileSource('/var/www/vhosts/'.
$domain.'/httpdocs/images/lg_image/'.$row['lg_image']);
$mediaFileSource->setContentType('image/jpeg');
try {
$service->post($mediaFileSource, $mediaLinkHref);
} catch (Zend_Gdata_App_Exception $e) {
echo '<div style="border: 1px solid red;
padding:
10px;"><h3>Image Post Error:</h3>'.var_dump($e).'</div>';
}
echo '[success] product_id:'.$row['product_ID'].'<hr
/>';;
$num_items++;
}
catch(Exception $e){
echo '<span style="color: red;">[error]
product_id:'.$row
['product_ID'].' - ['.$e.']</span><hr />';
$num_errors++;
}
echo '<br />';
}
echo '<br />'.$num_items.' successfully uploaded. '.$num_errors.'
errors.<br />';
endHTML();
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Base Data API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Base-data-API?hl=en
-~----------~----~----~----~------~----~------~--~---