【问题标题】:How to get all Blogger post properties with Zend GData如何使用 Zend GData 获取所有 Blogger 帖子属性
【发布时间】:2012-10-01 00:57:57
【问题描述】:

我有这样的代码:

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、作者姓名、回复等其他属性吗?

【问题讨论】:

    标签: php zend-framework gdata


    【解决方案1】:

    我正在寻找相同的解决方案。 原来所有的属性都存放在$object->property->text

    所以如果你想获取消息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;
    
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-24
      相关资源
      最近更新 更多