我使用zend_feed进行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');
但它不起作用,你能说我怎么能这样做
答案 0 :(得分: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);