diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2015-03-31 10:18:08 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2015-03-31 10:19:06 +0200 |
commit | 5a5eda55dcdb636e243bb4afcdac2e1cc6f4787a (patch) | |
tree | 22000698d6a452024f276fd163df7a072eae7016 /vendor/fguillot/picofeed/docs | |
parent | 539b3823ade372cc2d076980e513aec57b4c8b06 (diff) |
update picofeed
Diffstat (limited to 'vendor/fguillot/picofeed/docs')
-rw-r--r-- | vendor/fguillot/picofeed/docs/feed-parsing.markdown | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/vendor/fguillot/picofeed/docs/feed-parsing.markdown b/vendor/fguillot/picofeed/docs/feed-parsing.markdown index 6e7f2fdc2..1ee21451d 100644 --- a/vendor/fguillot/picofeed/docs/feed-parsing.markdown +++ b/vendor/fguillot/picofeed/docs/feed-parsing.markdown @@ -176,6 +176,44 @@ catch (PicoFeedException $e) { } ``` +HTTP basic auth +--------------- +If a feed requires basic auth headers, you can pass them as parameters to the **download** method, e.g.: + +```php +try { + $reader = new Reader; + + $user = 'john'; + $password = 'doe'; + + // Provide those values to the download method + $resource = $reader->download('http://linuxfr.org/news.atom', '', '', $user, $password); + + // Return true if the remote content has changed + if ($resource->isModified()) { + + $parser = $reader->getParser( + $resource->getUrl(), + $resource->getContent(), + $resource->getEncoding() + ); + + $feed = $parser->execute(); + + // Save your feed in your database + // ... + + } + else { + + echo 'Not modified, nothing to do!'; + } +} +catch (PicoFeedException $e) { + // Do something... +} +``` Feed and item properties ------------------------ @@ -205,6 +243,45 @@ $feed->items[0]->getContent(); // Item content (filtered or raw) $feed->items[0]->isRTL(); // Return true if the item language is Right-To-Left ``` +Get raw XML tags/attributes or non standard tags for items +---------------------------------------------------------- + +Get the original `guid` tag for RSS 2.0 feeds: + +```php +echo $feed->items[0]->getTag('guid'); +``` + +Get a specific attribute value: + +```php +echo $feed->items[1]->getTag('category', 'term'); +``` + +Get value of namespaced tag: + +```php +echo $feed->items[1]->getTag('wfw:commentRss'); +``` + +Get attribute value of a namespaced tag: + +```php +echo $feed->items[0]->getTag('media:content', 'url'); +``` + +Get the xml of the item (returns a SimpleXMLElement instance): + +```php +$simplexml = $feed->items[0]->xml; +``` + +Get the list of namespaces: + +```php +print_r($feed->items[0]->namespaces); +``` + RTL language detection ---------------------- |