Zend_Feed-ConsumingAtom.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.feed.consuming-atom">
  4. <title>Consuming an Atom Feed</title>
  5. <para>
  6. <classname>Zend_Feed_Atom</classname> is used in much the same way as <classname>Zend_Feed_Rss</classname>. It provides
  7. the same access to feed-level properties and iteration over entries in the feed. The main
  8. difference is in the structure of the Atom protocol itself. Atom is a successor to RSS; it is more
  9. generalized protocol and it is designed to deal more easily with feeds that provide their full
  10. content inside the feed, splitting RSS' <code>description</code> tag into two elements,
  11. <code>summary</code> and <code>content</code>, for that purpose.
  12. </para>
  13. <example id="zend.feed.consuming-atom.example.usage">
  14. <title>Basic Use of an Atom Feed</title>
  15. <para>
  16. Read an Atom feed and print the <code>title</code> and <code>summary</code> of each entry:
  17. </para>
  18. <programlisting role="php"><![CDATA[
  19. $feed = new Zend_Feed_Atom('http://atom.example.com/feed/');
  20. echo 'The feed contains ' . $feed->count() . ' entries.' . "\n\n";
  21. foreach ($feed as $entry) {
  22. echo 'Title: ' . $entry->title() . "\n";
  23. echo 'Summary: ' . $entry->summary() . "\n\n";
  24. }
  25. ]]></programlisting>
  26. </example>
  27. <para>
  28. In an Atom feed you can expect to find the following feed properties:
  29. </para>
  30. <para>
  31. <itemizedlist>
  32. <listitem>
  33. <para><code>title</code> - The feed's title, same as RSS's channel title</para>
  34. </listitem>
  35. <listitem>
  36. <para><code>id</code> - Every feed and entry in Atom has a unique identifier</para>
  37. </listitem>
  38. <listitem>
  39. <para><code>link</code> - Feeds can have multiple links, which are distinguished by a
  40. <code>type</code> attribute</para>
  41. <para>
  42. The equivalent to RSS's channel link would be <code>type="text/html"</code>. If the link
  43. is to an alternate version of the same content that's in the feed, it would have a
  44. <code>rel="alternate"</code> attribute.
  45. </para>
  46. </listitem>
  47. <listitem>
  48. <para><code>subtitle</code> - The feed's description, equivalent to RSS' channel description
  49. </para>
  50. <para><code>author->name()</code> - The feed author's name</para>
  51. <para><code>author->email()</code> - The feed author's email address</para>
  52. </listitem>
  53. </itemizedlist>
  54. </para>
  55. <para>
  56. Atom entries commonly have the following properties:
  57. </para>
  58. <para>
  59. <itemizedlist>
  60. <listitem>
  61. <para><code>id</code> - The entry's unique identifier</para>
  62. </listitem>
  63. <listitem>
  64. <para><code>title</code> - The entry's title, same as RSS item titles</para>
  65. </listitem>
  66. <listitem>
  67. <para><code>link</code> - A link to another format or an alternate view of this entry</para>
  68. </listitem>
  69. <listitem>
  70. <para><code>summary</code> - A summary of this entry's content</para>
  71. </listitem>
  72. <listitem>
  73. <para><code>content</code> - The full content of the entry; can be skipped if the feed just
  74. contains summaries</para>
  75. </listitem>
  76. <listitem>
  77. <para><code>author</code> - with <code>name</code> and <code>email</code> sub-tags like
  78. feeds have</para>
  79. </listitem>
  80. <listitem>
  81. <para><code>published</code> - the date the entry was published, in RFC 3339 format</para>
  82. </listitem>
  83. <listitem>
  84. <para><code>updated</code> - the date the entry was last updated, in RFC 3339 format</para>
  85. </listitem>
  86. </itemizedlist>
  87. </para>
  88. <para>
  89. For more information on Atom and plenty of resources, see
  90. <ulink url="http://www.atomenabled.org/">http://www.atomenabled.org/</ulink>.
  91. </para>
  92. </sect1>
  93. <!--
  94. vim:se ts=4 sw=4 et:
  95. -->