rsslib/README.md
2023-08-13 18:09:44 -04:00

82 lines
No EOL
1.8 KiB
Markdown

# RssLib
RssLib is a library used to parse RSS feeds and return the data in a usable format.
## Table of contents
<!-- TOC -->
* [RssLib](#rsslib)
* [Table of contents](#table-of-contents)
* [Installation](#installation)
* [Compile from source](#compile-from-source)
* [Requirements](#requirements)
* [Documentation](#documentation)
* [License](#license)
<!-- TOC -->
## Installation
The library can be installed using ncc:
```bash
ncc install -p "nosial/libs.rss=latest@n64"
```
or by adding the following to your project.json file under the `build.dependencies` section:
```json
{
"name": "net.nosial.rsslib",
"version": "latest",
"source_type": "remote",
"source": "nosial/libs.rsslib=latest@n64"
}
```
If you don't have the n64 source configured, you can add it by running the following command:
```bash
ncc source add --name n64 --type gitlab --host git.n64.cc
```
## Compile from source
To compile the library from source, you need to have [ncc](https://git.n64.cc/nosial/ncc) installed, then run the
following command:
```bash
ncc build
```
## Requirements
The library requires PHP 8.0 or higher.
## Documentation
The library is designed to be used as a dependency in other projects, and as such, does not have a command-line
interface. The library is designed to be used as follows:
```php
try
{
$feed = \RssLib\RssLib::getFeed('https://rss.nytimes.com/services/xml/rss/nyt/World.xml');
}
catch(\RssLib\Exceptions\RssFeedException $e)
{
echo $e->getMessage();
exit(1);
}
print("Title: {$feed->getTitle()}\n");
print("Description: {$feed->getDescription()}\n");
foreach($feed->getItems() as $item)
{
print("Item: {$item->getTitle()}\n");
print("Description: {$item->getDescription()}\n");
print("Link: {$item->getLink()}\n");
}
```
## License
Distributed under the MIT License. See `LICENSE` for more information.