0

我正在使用 zend_feed 生成提要,这是代码,它工作正常,但我还需要添加一些关于图像的更多信息,

$feedData = array(
            'title' => $feed->feedParams['title'],
            'description' => $feed->feedParams['description'],
            'link' => $feed->getSiteUrl() . $feed->feedParams['link'],
            'charset' => $feed->feedParams['charset'],
             'url' => $feed->getSiteUrl() . $feed->feedParams['image'],
            'ttl' => $feed->feedParams['ttl'],
            'entries' => $feed->getFeedContent()
        );
$feed = Zend_Feed::importArray($feedData, 'rss');

结果是

<image>
  <url>http://local.here/assets/img/icons/feed.png</url>
  <title><![CDATA[here Uutiset]]></title>
  <link>http://local.here/uutiset</link>
</image>

但是我需要

<image>
<url>http://www.edilex.fi/images/rss.gif</url>
<title>Edilex</title>
<link>http://www.edilex.fi/</link>
<width>129</width>
<height>76</height>
</image>

所以我试试这个,但不工作

$feedData = array(
            'title' => $feed->feedParams['title'],
            'description' => $feed->feedParams['description'],
            'link' => $feed->getSiteUrl() . $feed->feedParams['link'],
            'charset' => $feed->feedParams['charset'],
            'image' => array(
                'url' => $feed->getSiteUrl() . $feed->feedParams['image'],
                'width' => 120,
                'hight' => 130
            ),
            'ttl' => $feed->feedParams['ttl'],
            'entries' => $feed->getFeedContent()
        );
$feed = Zend_Feed::importArray($feedData, 'rss');

但它不起作用,你能告诉我我该怎么做吗

4

1 回答 1

1

看起来可选的宽度和高度参数没有在 Zend_Feed_Rss 中映射

摘自 _mapFeedHeaders

if (!empty($array->image)) {
            $image = $this->_element->createElement('image');
            $url = $this->_element->createElement('url', $array->image);
            $image->appendChild($url);
            $imagetitle = $this->_element->createElement('title');
            $imagetitle->appendChild($this->_element->createCDATASection($array->title));
            $image->appendChild($imagetitle);
            $imagelink = $this->_element->createElement('link', $array->link);
            $image->appendChild($imagelink);

            $channel->appendChild($image);
于 2012-05-24T10:29:46.520 回答