hi to all, i got problem inserting data using google base, below are my code:
function closure_addGbaseAttribute($attribute, $value, $type, & $newEntry){ if( trim($value) != "" ){ $newEntry->addGbaseAttribute($attribute, $value, $type); } } require 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_Gbase'); // Parameters for ClientAuth authentication $service = Zend_Gdata_Gbase::AUTH_SERVICE_NAME; $field = get_property_gbase_account(); $user = $field[0]["username"]; $pass = $field[0]["password"]; #echo $user." / ". $pass; // Create an authenticated HTTP client $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service); // Create an instance of the Base service $service = new Zend_Gdata_Gbase($client); # Load records $var = get_all_property(); #print_r($var); $var_count = count($var); $message = ""; for ($ctr=0; $ctr < $var_count; $ctr++) { # Load property $property = get_property($var[$ctr]["property_ID"]); # required fields are required by google base! if (( (int) $property['property']['property_ListPrice'] > 0) && ( (int) $property['property']['property_ID'] > 0)) { if (trim($property['property']['property_Title'])=='') $property['property']['property_Title'] = "None"; if (trim($property['property']['property_Details'])=='') $property['property']['property_Details'] = "None"; $property_status = get_property_status($property['property'] ['property_StatusID']); $property_type = get_property_type( $property['property'] ['property_TypeID'] ); $data = array(); # echo $property['property']['property_Title']; # required fields: $data['title'] = $property['property']['property_Title']; $data['description'] = $property['property']['property_Details']; $data['price'] = $property['property']['property_ListPrice']; # optional fields: # not all these fields are submitted to google base # to submit a field, use closure_addGbaseAttribute() below $data['property_id'] = $property['property']['property_ID']; $data['bathrooms'] = $property['property']['property_Bathrooms']; $data['bedrooms'] = $property['property']['property_Bedrooms']; $data['broker'] = "{$property['agents'][0]['agent_FirstName']} {$property['agents'][0]['agent_LastName']}"; $data['listing_status'] = $property_status['status_Title']; $data['mls_listing_id'] = $property['property']['property_MLS']; $data['property_type'] = $property_type['type_Title']; $newEntry = $service->newItemEntry(); $newEntry->title = $service->newTitle($data['title']); $newEntry->content = $service->newContent($data['description']); $newEntry->content->type = 'text'; $newEntry->itemType = "Real Estate"; closure_addGbaseAttribute("price", $data['price'], "floatUnit", $newEntry); //required! closure_addGbaseAttribute("property_id", $data['property_id'], "number", $newEntry); //optional field closure_addGbaseAttribute("broker", $data['broker'], "text", $newEntry); closure_addGbaseAttribute("property_type", $data['property_type'], "text", $newEntry); closure_addGbaseAttribute("listing_status", $data['listing_status'], "text", $newEntry); closure_addGbaseAttribute("bathrooms", $data['bathrooms'], "number", $newEntry); closure_addGbaseAttribute("bedrooms", $data['bedrooms'], "number", $newEntry); $dryRun = false; //set to true! unless you are just testing $query = $service->newSnippetQuery(); $query->setBq('[title:'.$newEntry->title.']'); $feed = $service->getGbaseSnippetFeed($query); #if(count($feed->entries) == 0) #if(trim($property['property']['property_GbaseEditURL']) == "") try { $action = "updated"; $entry = $service->getGbaseItemEntry($property['property'] ['property_GbaseEditURL']); $entry->title = $service->newTitle($data['title']); $entry->content = $service->newContent($data['details']); //change price $baseAttributes = $entry->getGbaseAttribute("price"); $baseAttributes[0]->text = $data['price']; //change property_id $baseAttributes = $entry->getGbaseAttribute("property_id"); $baseAttributes[0]->text = $data['property_id']; //change property_type $baseAttributes = $entry->getGbaseAttribute("property_type"); $baseAttributes[0]->text = $data['type']; //change lot_size $baseAttributes = $entry->getGbaseAttribute("lot_size"); $baseAttributes[0]->text = $data['lot_size']; //change year $baseAttributes = $entry->getGbaseAttribute("year"); $baseAttributes[0]->text = $data['year']; //change bathrooms $baseAttributes = $entry->getGbaseAttribute("bathrooms"); $baseAttributes[0]->text = $data['bathrooms']; //change bedrooms $baseAttributes = $entry->getGbaseAttribute("bedrooms"); $baseAttributes[0]->text = $data['bedrooms']; //change location //$baseAttributes = $entry->getGbaseAttribute("location"); //$baseAttributes[0]->text = $data['location']; //change country $baseAttributes = $entry->getGbaseAttribute("country"); $baseAttributes[0]->text = $data['country']; $entry->save($dryRun); /*$service->delete($entry); $createdEntry = $service->insertGbaseItem($newEntry, $dryRun);*/ $message .= '<font style="color: green;">Successfully Updated Property "'.$newEntry->title.'".</font><br>'; } catch(Exception $e) { $action = "created"; $createdEntry = $service->insertGbaseItem($newEntry, $dryRun); $link = $createdEntry->getLink(); $editlink = $createdEntry->getEditLink(); $gbaseediturl = $editlink->getHref(); $gbaseurl = $link[0]->getHref(); $message .= '<font style="color: green;">Successfully Pushed Property "'.$newEntry->title.'" to Google Base.</font><br>'; update_property_gbase_URL($data['property_id'], $gbaseurl, $gbaseediturl); } /* if(trim($property['property']['property_GbaseEditURL']) == "") { $action = "created"; $createdEntry = $service->insertGbaseItem($newEntry, $dryRun); $link = $createdEntry->getLink(); $editlink = $createdEntry->getEditLink(); $gbaseediturl = $editlink->getHref(); $gbaseurl = $link[0]->getHref(); $message .= '<font style="color: green;">Successfully Pushed Property "'.$newEntry->title.'" to Google Base.</font><br>'; update_property_gbase_URL($data['property_id'], $gbaseurl, $gbaseediturl); } else { try { $action = "updated"; #$entry = $service->getGbaseItemEntry($property['property'] ['property_GbaseEditURL']); $service->delete($entry); $createdEntry = $service->insertGbaseItem($newEntry, $dryRun); $message .= '<font style="color: green;">Successfully Updated Property "'.$newEntry->title.'".</font><br>'; } catch(Exception $e) { $message .= '<font style="color: #FF0000;">An error has occured with property "'.$newEntry->title.'". This results from bad data.</ font><br>'; } }*/ } } when running that code i come up with this error: Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 400' in /usr/local/www/vhosts/ aic/theharwoodgrp.com/htdocs/admin/Zend/Gdata/App.php:467 Stack trace: #0 /usr/local/www/vhosts/aic/theharwoodgrp.com/htdocs/admin/Zend/Gdata/ App.php(662): Zend_Gdata_App->post(Object(Zend_Gdata_Gbase_ItemEntry), 'http://www.goog...') #1 /usr/local/www/vhosts/aic/theharwoodgrp.com/ htdocs/admin/Zend/Gdata/Gbase.php(149): Zend_Gdata_App- >insertEntry(Object(Zend_Gdata_Gbase_ItemEntry), 'http://www.goog...', 'Zend_Gdata_Gbas...') #2 /usr/local/www/vhosts/aic/theharwoodgrp.com/ htdocs/admin/property_gbase.php(155): Zend_Gdata_Gbase- >insertGbaseItem(Object(Zend_Gdata_Gbase_ItemEntry), false) #3 {main} thrown in /usr/local/www/vhosts/aic/theharwoodgrp.com/htdocs/admin/ Zend/Gdata/App.php on line 467 thanks in advance for whatever support you can give. rni -- 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 google-base-data-...@googlegroups.com. To unsubscribe from this group, send email to google-base-data-api+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-base-data-api?hl=en.