Atom Feedを出力 | zend framework

http://framework.zend.com/manual/1.11/en/zend.feed.html

http://framework.zend.com/manual/1.11/en/zend.feed.consuming-atom.html

http://framework.zend.com/manual/1.11/en/zend.feed.writer.html

atom feedを出力します。

// 空のfeedを作成
$feed = new Zend_Feed_Writer_Feed;
$feed->setTitle(‘blog.bbtune’);
$feed->setLink(‘http://blog.bbtune.com’);
$feed->setFeedLink(‘http://blog.bbtune.com/atom’, ‘atom’);
$feed->addAuthor(array(
‘name’ => ‘Junichi Otake’,
‘uri’ => ‘http://blog.bbtune.com’,
));
$feed->setDateModified(time());
// エントリーを追加
$entry = $feed->createEntry();
$entry->setTitle(‘create an atom feed’);
$entry->setLink(‘http://blog.bbtune.com/’);
$entry->addAuthor(array(
‘name’ => ‘Junichi Otake’,
‘uri’ => ‘http://blog.bbtune.com’,
));
$entry->setDateModified(time());
$entry->setDateCreated(time());
$entry->setDescription(‘generated a feed by zend framework zend_feed_writer’);
$entry->setContent(‘generated a feed by zend framework zend_feed_writer’);
$feed->addEntry($entry);

// 出力
$out = $feed->export(‘atom’);

実行したらまさかのエラー

PHP Fatal error: Class ‘DOMDocument’ not found in Zend/Feed/Writer/Renderer/Feed/Atom.php on line 73

http://www.php.net/manual/ja/dom.requirements.php

yum install php-xml

outを出力すると

<?xml version=”1.0″ encoding=”UTF-8″?>
<feed xmlns=”http://www.w3.org/2005/Atom”>
<title type=”text”>blog.bbtune</title>
<updated>2012-06-26T17:04:26+09:00</updated>
<generator uri=”http://framework.zend.com” version=”1.11.6″>Zend_Feed_Writer</generator>
<link rel=”alternate” type=”text/html” href=”http://blog.bbtune.com”/>
<link rel=”self” type=”application/atom+xml” href=”http://blog.bbtune.com/atom”/>
<id>http://blog.bbtune.com</id>
<author>
<name>Junichi Otake</name>
<uri>http://blog.bbtune.com</uri>
</author>
<entry xmlns:xhtml=”http://www.w3.org/1999/xhtml”>
<title type=”html”><![CDATA[create an atom feed]]></title>
<summary type=”html”><![CDATA[generated a feed by zend framework zend_feed_writer]]></summary>
<published>2012-06-26T17:04:26+09:00</published>
<updated>2012-06-26T17:04:26+09:00</updated>
<link rel=”alternate” type=”text/html” href=”http://blog.bbtune.com/”/>
<id>http://blog.bbtune.com/</id>
<author>
<name>Junichi Otake</name>
<uri>http://blog.bbtune.com</uri>
</author>
<content xmlns:xhtml=”http://www.w3.org/1999/xhtml” type=”xhtml”>
<xhtml:div xmlns:xhtml=”http://www.w3.org/1999/xhtml”>generated a feed by zend framework zend_feed_writer</xhtml:div>
</content>
</entry>
</feed>

終わり。

This entry was posted on 火曜日, 6月 26th, 2012 at 4:43 PM and is filed under php, zend. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。