Giter Club home page Giter Club logo

youtube-rss-parser's Introduction

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.

Installation

Use Composer:

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. Code released under the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.