annotate vendor/zendframework/zend-feed/doc/book/consuming-atom.md @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
rev   line source
Chris@0 1 # Consuming Atom Feeds
Chris@0 2
Chris@0 3 `Zend\Feed\Reader\Feed\Atom` is used in much the same way as
Chris@0 4 `Zend\Feed\Reader\Feed\Rss`. It provides the same access to feed-level
Chris@0 5 properties and iteration over entries in the feed. The main difference is in the
Chris@0 6 structure of the Atom protocol itself. Atom is a successor to RSS; it is a
Chris@0 7 more generalized protocol and it is designed to deal more easily with feeds that
Chris@0 8 provide their full content inside the feed, splitting RSS' `description` tag
Chris@0 9 into two elements, `summary` and `content`, for that purpose.
Chris@0 10
Chris@0 11 ## Basic Use of an Atom Feed
Chris@0 12
Chris@0 13 Read an Atom feed and print the `title` and `summary` of each entry:
Chris@0 14
Chris@0 15 ```php
Chris@0 16 $feed = Zend\Feed\Reader\Reader::import('http://atom.example.com/feed/');
Chris@0 17 echo 'The feed contains ' . $feed->count() . ' entries.' . "\n\n";
Chris@0 18 foreach ($feed as $entry) {
Chris@0 19 echo 'Title: ' . $entry->getTitle() . "\n";
Chris@0 20 echo 'Description: ' . $entry->getDescription() . "\n";
Chris@0 21 echo 'URL: ' . $entry->getLink() . "\n\n";
Chris@0 22 }
Chris@0 23 ```
Chris@0 24
Chris@0 25 > ## Importing requires an HTTP client
Chris@0 26 >
Chris@0 27 > To import a feed, you will need to have an [HTTP client](zend.feed.http-clients)
Chris@0 28 > available.
Chris@0 29 >
Chris@0 30 > If you are not using zend-http, you will need to inject `Reader` with the HTTP
Chris@0 31 > client. See the [section on providing a client to Reader](http-clients.md#providing-a-client-to-reader).
Chris@0 32
Chris@0 33 In an Atom feed, you can expect to find the following feed properties:
Chris@0 34
Chris@0 35 - `title`: The feed's title, same as RSS' channel title.
Chris@0 36 - `id`: Every feed and entry in Atom has a unique identifier.
Chris@0 37 - `link`: Feeds can have multiple links, which are distinguished by a `type`
Chris@0 38 attribute. The equivalent to RSS's channel link would be `type="text/html"`.
Chris@0 39 If the link is to an alternate version of the same content that's in the feed,
Chris@0 40 it would have a `rel="alternate"` attribute.
Chris@0 41 - `subtitle`: The feed's description, equivalent to RSS' channel description.
Chris@0 42 - `author`: The feed's author, with `name` and `email` sub-tags.
Chris@0 43
Chris@0 44 Atom entries commonly have the following properties:
Chris@0 45
Chris@0 46 - `id`: The entry's unique identifier.
Chris@0 47 - `title`: The entry's title, same as RSS item titles.
Chris@0 48 - `link`: A link to another format or an alternate view of this entry.
Chris@0 49 The link property of an atom entry typically has an `href` attribute.
Chris@0 50 - `summary`: A summary of this entry's content.
Chris@0 51 - `content`: The full content of the entry; can be skipped if the feed just
Chris@0 52 contains summaries.
Chris@0 53 - `author`: with `name` and `email` sub-tags like feeds have.
Chris@0 54 - `published`: the date the entry was published, in RFC 3339 format.
Chris@0 55 - `updated`: the date the entry was last updated, in RFC 3339 format.
Chris@0 56
Chris@0 57 Where relevant, `Zend\Feed` supports a number of common RSS extensions including
Chris@0 58 Dublin Core; Content, Slash, Syndication, and Syndication/Thread; and several
Chris@0 59 others in common use on blogs.
Chris@0 60
Chris@0 61 For more information on Atom and plenty of resources, see
Chris@0 62 [http://www.atomenabled.org/](http://www.atomenabled.org/).