如何使用Zend GData获取所有Blogger帖子属性

时间:2012-06-28 08:54:22

标签: php zend-framework 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,url,作者姓名,回复?

1 个答案:

答案 0 :(得分:2)

我正在寻找相同的解决方案。 事实证明,所有属性都存储在$ object->财产而>文本

因此,如果您想获取消息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;

  }