PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Posting Entries to Google Servers

The Zend_Gdata object has a function insertEntry() with which you can upload data to save new entries to Google Data services.

You can use the data model classes for each service to construct the appropriate entry to post to Google's services. The insertEntry() function will accept a child of Zend_Gdata_App_Entry as data to post to the service. The method returns a child of Zend_Gdata_App_Entry which represents the state of the entry as it was returned from the server.

Alternatively, you could construct the XML structure for an entry as a string and pass the string to the insertEntry() function.

<?php
$gdata 
= new Zend_Gdata($authenticatedHttpClient);

$entry $gdata->newEntry();
$entry->title $gdata->newTitle('Playing football at the park');
$content =
    
$gdata->newContent('We will visit the park and play football');
$content->setType('text');
$entry->content $content;

$entryResult $gdata->insertEntry($entry,
        
'http://www.blogger.com/feeds/blogID/posts/default');

echo 
'The <id> of the resulting entry is: ' $entryResult->id->text;

To post entries, you must be using an authenticated Zend_Http_Client that you created using the Zend_Gdata_AuthSub or Zend_Gdata_ClientLogin classes.

Zend Framework