Zend_Feed-ConsumingAtom.xml 4.5 KB

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