Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gbuckingham89/youtube-rss-parser
A simple parser for reading a YouTube RSS feed.
https://github.com/gbuckingham89/youtube-rss-parser
php php-library php-youtube-api rss rss-feed-parser rss-feed-scraper rss-reader youtube youtube-api youtube-channel
Last synced: about 2 months ago
JSON representation
A simple parser for reading a YouTube RSS feed.
- Host: GitHub
- URL: https://github.com/gbuckingham89/youtube-rss-parser
- Owner: gbuckingham89
- License: mit
- Archived: true
- Created: 2017-04-26T18:04:32.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-03-12T11:07:09.000Z (over 3 years ago)
- Last Synced: 2024-03-20T06:03:18.265Z (8 months ago)
- Topics: php, php-library, php-youtube-api, rss, rss-feed-parser, rss-feed-scraper, rss-reader, youtube, youtube-api, youtube-channel
- Language: PHP
- Size: 12.7 KB
- Stars: 22
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gbuckingham89/youtube-rss-parser
A simple PHP parser for reading a YouTube RSS feed. It provides a object oriented interface for accessing the RSS feed data. Perfect for when you need to access recent videos, but don't want to use the full YouTube API.
## Requirements
Requires PHP 7.1.8 or greater. Uses *guzzlehttp/guzzle* as a HTTP client and *nesbot/carbon* for handling dates. See `composer.json` for more details.
If you require support for an older PHP version (>=5.5), see [release v0.1.0](https://github.com/gbuckingham89/youtube-rss-parser/tree/v0.1.0).
## Installation
Use [Composer](http://getcomposer.org):
composer require gbuckingham89/youtube-rss-parser
## Usage
To get started you'll need to create an instance of the parser;
$parser = new \Gbuckingham89\YouTubeRSSParser\Parser();
You can then load the RSS feed from a URL:
$rss_url = 'https://www.youtube.com/feeds/videos.xml?channel_id=CHANNEL_ID_HERE';
$parser->loadUrl($rss_url);Or, if you're in a hurry, you can also pass in the URL as the first argument when you instantiate the parser object.
Or if you've already got the XML of RSS feed content as a string, you can load it via that:
$rss_content = 'RSS FEED CONTENT';
$parser->loadString($rss_content);Both of these methods then return an instance of `\Gbuckingham89\YouTubeRSSParser\Channel`. You can also access the `channel` property or call the `channel` method on the `Parser` instance to get the `Channel` object.
You can then access the properties of the channel (see the class file). The `videos` property is an array of `\Gbuckingham89\YouTubeRSSParser\Video` objects, on which you can access the properties of the video (see the class file).
Prefer working with arrays? Or JSON? You can simply call the `toArray` or `toJson` on both the `Channel` and `Videos` objects.
## Contributing / bugs
Just open an issue / pull request if you find a bug, or want to contribute!
## Copyright and license
Code and documentation copyright 2017 [George Buckingham](https://www.georgebuckingham.com). Code released under the [MIT License](https://github.com/gbuckingham89/eloquent-uuid/blob/master/LICENSE).