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