2012-06-28 76 views
0

得到所有博客帖子的屬性我有這樣的代碼:如何與Zend的GData

require_once 'Zend/Loader.php'; 
Zend_Loader::loadClass('Zend_Gdata'); 
Zend_Loader::loadClass('Zend_Gdata_Query'); 
Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); 

$user = 'usser'; 
$pass = 'pass'; 
$service = 'blogger'; 

$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service, null, 
     Zend_Gdata_ClientLogin::DEFAULT_SOURCE, null, null, 
     Zend_Gdata_ClientLogin::CLIENTLOGIN_URI, 'GOOGLE'); 
$gdClient = new Zend_Gdata($client); 

$blogID='someID'; 
$query = new Zend_Gdata_Query('http://www.blogger.com/feeds/' . $this->blogID . '/posts/default'); 

    $feed = $gdClient->getFeed($query); 
    print $entry->title->text; 

問題是,我可以只打印幾個屬性,如標題和描述。任何想法如何打印其他屬性,如id,網址,作者姓名,回覆?

回答

2

我正在尋找相同的解決方案。 事實證明,所有屬性都存儲在$對象 - >性財產>文本

所以,如果你想獲得消息ID,例如,你必須這樣做:

<?php 
require_once 'Zend/Loader.php'; 
Zend_Loader::loadClass('Zend_Gdata'); 
Zend_Loader::loadClass('Zend_Gdata_Query'); 
Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); 

$user = 'usser'; 
$pass = 'pass'; 
$service = 'blogger'; 

$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service, null, 
     Zend_Gdata_ClientLogin::DEFAULT_SOURCE, null, null, 
     Zend_Gdata_ClientLogin::CLIENTLOGIN_URI, 'GOOGLE'); 
$gdClient = new Zend_Gdata($client); 

$blogID='someID'; 
$query = new Zend_Gdata_Query('http://www.blogger.com/feeds/' . $this->blogID . '/posts/default'); 

    $feed = $gdClient->getFeed($query); 
// for all array witch properties print object $feed; 
//print_r($feed); 
    foreach ($feed as $feeds => $f){ 
    $idText = explode('-', $f->id->text); 
    $postID = $idText[2]; 
    $title = $ou->title->text; 

    }