diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-11-09 11:44:09 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-11-09 11:44:09 +0100 |
commit | b9e330109b58fac55c3728dd3c543552fcabd353 (patch) | |
tree | 93d386ca453b4b90f517018eb63a4b64df22e8ba /vendor/fguillot/picofeed/example.php | |
parent | e5d18a22c3c15acf61f97da4965a551b83df05cb (diff) |
update picofeed to 0.1.0
Diffstat (limited to 'vendor/fguillot/picofeed/example.php')
-rw-r--r-- | vendor/fguillot/picofeed/example.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/fguillot/picofeed/example.php b/vendor/fguillot/picofeed/example.php new file mode 100644 index 000000000..6bf9b6e20 --- /dev/null +++ b/vendor/fguillot/picofeed/example.php @@ -0,0 +1,45 @@ +<?php + +require 'vendor/autoload.php'; + +use PicoFeed\Reader\Reader; +use PicoFeed\PicoFeedException; + +try { + + // Fetch from your database the previous values of the Etag and LastModified headers + $etag = '...'; + $last_modified = '...'; + + $reader = new Reader; + + // Provide those values to the download method + $resource = $reader->download('http://linuxfr.org/news.atom', $last_modified, $etag); + + if ($resource->isModified()) { + + $parser = $reader->getParser( + $resource->getUrl(), + $resource->getContent(), + $resource->getEncoding() + ); + + $feed = $parser->execute(); + + // Save your feed in your database + // ... + + // Store the Etag and the LastModified headers in your database + $etag = $resource->getEtag(); + $last_modified = $resource->getLastModified(); + + // ... + } + else { + + echo 'Not modified, nothing to do!'; + } +} +catch (PicoFeedException $e) { + // Do something... +} |