|
|
@@ -1,12 +1,12 @@
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
<!-- Reviewed: no -->
|
|
|
<sect1 id="zend.feed.importing">
|
|
|
-
|
|
|
<title>Importing Feeds</title>
|
|
|
|
|
|
<para>
|
|
|
<classname>Zend_Feed</classname> enables developers to retrieve feeds very easily. If you
|
|
|
- know the <acronym>URI</acronym> of a feed, simply use the <methodname>Zend_Feed::import()</methodname> method:
|
|
|
+ know the <acronym>URI</acronym> of a feed, simply use the
|
|
|
+ <methodname>Zend_Feed::import()</methodname> method:
|
|
|
</para>
|
|
|
|
|
|
<programlisting language="php"><![CDATA[
|
|
|
@@ -29,28 +29,26 @@ $feedFromPHP = Zend_Feed::importString($feedString);
|
|
|
<para>
|
|
|
In each of the examples above, an object of a class that extends
|
|
|
<classname>Zend_Feed_Abstract</classname> is returned upon success, depending on the type of
|
|
|
- the feed. If an <acronym>RSS</acronym> feed were retrieved via one of the import methods above, then a
|
|
|
- <classname>Zend_Feed_Rss</classname> object would be returned. On the other hand, if an Atom
|
|
|
- feed were imported, then a <classname>Zend_Feed_Atom</classname> object is returned. The
|
|
|
- import methods will also throw a <classname>Zend_Feed_Exception</classname> object upon
|
|
|
- failure, such as an unreadable or malformed feed.
|
|
|
+ the feed. If an <acronym>RSS</acronym> feed were retrieved via one of the import methods
|
|
|
+ above, then a <classname>Zend_Feed_Rss</classname> object would be returned. On the other
|
|
|
+ hand, if an Atom feed were imported, then a <classname>Zend_Feed_Atom</classname> object is
|
|
|
+ returned. The import methods will also throw a <classname>Zend_Feed_Exception</classname>
|
|
|
+ object upon failure, such as an unreadable or malformed feed.
|
|
|
</para>
|
|
|
|
|
|
<sect2 id="zend.feed.importing.custom">
|
|
|
-
|
|
|
<title>Custom feeds</title>
|
|
|
|
|
|
<para>
|
|
|
<classname>Zend_Feed</classname> enables developers to create custom feeds very easily.
|
|
|
You just have to create an array and to import it with <classname>Zend_Feed</classname>.
|
|
|
- This array can be imported with <methodname>Zend_Feed::importArray()</methodname> or with
|
|
|
- <methodname>Zend_Feed::importBuilder()</methodname>. In this last case the array will be
|
|
|
- computed on the fly by a custom data source implementing
|
|
|
+ This array can be imported with <methodname>Zend_Feed::importArray()</methodname> or
|
|
|
+ with <methodname>Zend_Feed::importBuilder()</methodname>. In this last case the array
|
|
|
+ will be computed on the fly by a custom data source implementing
|
|
|
<classname>Zend_Feed_Builder_Interface</classname>.
|
|
|
</para>
|
|
|
|
|
|
<sect3 id="zend.feed.importing.custom.importarray">
|
|
|
-
|
|
|
<title>Importing a custom array</title>
|
|
|
|
|
|
<programlisting language="php"><![CDATA[
|
|
|
@@ -254,52 +252,56 @@ array(
|
|
|
|
|
|
<para>
|
|
|
References:
|
|
|
- <itemizedlist>
|
|
|
- <listitem>
|
|
|
- <para>
|
|
|
- <acronym>RSS</acronym> 2.0 specification: <ulink
|
|
|
- url="http://blogs.law.harvard.edu/tech/rss">RSS 2.0</ulink>
|
|
|
- </para>
|
|
|
- </listitem>
|
|
|
- <listitem>
|
|
|
- <para>
|
|
|
- Atom specification: <ulink
|
|
|
- url="http://tools.ietf.org/html/rfc4287">RFC 4287</ulink>
|
|
|
- </para>
|
|
|
- </listitem>
|
|
|
- <listitem>
|
|
|
- <para>
|
|
|
- WFW specification: <ulink
|
|
|
- url="http://wellformedweb.org/news/wfw_namespace_elements">Well
|
|
|
- Formed Web</ulink>
|
|
|
- </para>
|
|
|
- </listitem>
|
|
|
- <listitem>
|
|
|
- <para>
|
|
|
- iTunes specification: <ulink
|
|
|
- url="http://www.apple.com/itunes/store/podcaststechspecs.html">iTunes
|
|
|
- Technical Specifications</ulink>
|
|
|
- </para>
|
|
|
- </listitem>
|
|
|
- </itemizedlist>
|
|
|
</para>
|
|
|
|
|
|
+ <itemizedlist>
|
|
|
+ <listitem>
|
|
|
+ <para>
|
|
|
+ <acronym>RSS</acronym> 2.0 specification: <ulink
|
|
|
+ url="http://blogs.law.harvard.edu/tech/rss">RSS 2.0</ulink>
|
|
|
+ </para>
|
|
|
+ </listitem>
|
|
|
+
|
|
|
+ <listitem>
|
|
|
+ <para>
|
|
|
+ Atom specification: <ulink
|
|
|
+ url="http://tools.ietf.org/html/rfc4287">RFC 4287</ulink>
|
|
|
+ </para>
|
|
|
+ </listitem>
|
|
|
+
|
|
|
+ <listitem>
|
|
|
+ <para>
|
|
|
+ <acronym>WFW</acronym> specification: <ulink
|
|
|
+ url="http://wellformedweb.org/news/wfw_namespace_elements">Well
|
|
|
+ Formed Web</ulink>
|
|
|
+ </para>
|
|
|
+ </listitem>
|
|
|
+
|
|
|
+ <listitem>
|
|
|
+ <para>
|
|
|
+ iTunes specification: <ulink
|
|
|
+ url="http://www.apple.com/itunes/store/podcaststechspecs.html">iTunes
|
|
|
+ Technical Specifications</ulink>
|
|
|
+ </para>
|
|
|
+ </listitem>
|
|
|
+ </itemizedlist>
|
|
|
</sect3>
|
|
|
|
|
|
<sect3 id="zend.feed.importing.custom.importbuilder">
|
|
|
-
|
|
|
<title>Importing a custom data source</title>
|
|
|
|
|
|
<para>
|
|
|
- You can create a <classname>Zeed_Feed</classname> instance from any data source implementing
|
|
|
- <classname>Zend_Feed_Builder_Interface</classname>. You just have to implement the
|
|
|
- <methodname>getHeader()</methodname> and <methodname>getEntries()</methodname> methods to be able to use
|
|
|
- your object with <methodname>Zend_Feed::importBuilder()</methodname>. As a simple
|
|
|
- reference implementation, you can use <classname>Zend_Feed_Builder</classname>,
|
|
|
- which takes an array in its constructor, performs some minor validation, and then
|
|
|
- can be used in the <methodname>importBuilder()</methodname> method. The <methodname>getHeader()</methodname>
|
|
|
- method must return an instance of <classname>Zend_Feed_Builder_Header</classname>,
|
|
|
- and <methodname>getEntries()</methodname> must return an array of
|
|
|
+ You can create a <classname>Zeed_Feed</classname> instance from any data source
|
|
|
+ implementing <classname>Zend_Feed_Builder_Interface</classname>. You just have to
|
|
|
+ implement the <methodname>getHeader()</methodname> and
|
|
|
+ <methodname>getEntries()</methodname> methods to be able to use your object with
|
|
|
+ <methodname>Zend_Feed::importBuilder()</methodname>. As a simple reference
|
|
|
+ implementation, you can use <classname>Zend_Feed_Builder</classname>, which takes
|
|
|
+ an array in its constructor, performs some minor validation, and then can be used
|
|
|
+ in the <methodname>importBuilder()</methodname> method. The
|
|
|
+ <methodname>getHeader()</methodname> method must return an instance of
|
|
|
+ <classname>Zend_Feed_Builder_Header</classname>, and
|
|
|
+ <methodname>getEntries()</methodname> must return an array of
|
|
|
<classname>Zend_Feed_Builder_Entry</classname> instances.
|
|
|
</para>
|
|
|
|
|
|
@@ -329,16 +331,15 @@ $atomFeedFromArray =
|
|
|
$rssFeedFromArray =
|
|
|
Zend_Feed::importArray(new Zend_Feed_Builder($array), 'rss');
|
|
|
]]></programlisting>
|
|
|
-
|
|
|
</sect3>
|
|
|
|
|
|
<sect3 id="zend.feed.importing.custom.dump">
|
|
|
-
|
|
|
<title>Dumping the contents of a feed</title>
|
|
|
|
|
|
<para>
|
|
|
To dump the contents of a <classname>Zend_Feed_Abstract</classname> instance, you
|
|
|
- may use <methodname>send()</methodname> or <methodname>saveXml()</methodname> methods.
|
|
|
+ may use <methodname>send()</methodname> or <methodname>saveXml()</methodname>
|
|
|
+ methods.
|
|
|
</para>
|
|
|
|
|
|
<programlisting language="php"><![CDATA[
|
|
|
@@ -350,11 +351,8 @@ print $feed->saveXML();
|
|
|
// send http headers and dump the feed
|
|
|
$feed->send();
|
|
|
]]></programlisting>
|
|
|
-
|
|
|
</sect3>
|
|
|
-
|
|
|
</sect2>
|
|
|
-
|
|
|
</sect1>
|
|
|
<!--
|
|
|
vim:se ts=4 sw=4 et:
|