Coder Social home page Coder Social logo

feed-builder's Introduction

Feed builder

Library for building and validating RSS 2.0 and Atom 1.0 feeds. Conforms with RSS 2.0 and Atom 1.0 specifications.

Note

Validator not fully completed, no tests, pre-release.

Installation

Install via composer with command:

$ php composer.phar require 'anh/feed-builder:~1.0'

Usage

Atom 1.0 example

<?php

require 'vendor/autoload.php';

use Anh\FeedBuilder\FeedBuilder;

$feed = new FeedBuilder();

$feed
    ->setType('atom')
    ->fromArray(array(
        'title' => 'Another feed title',
        'author' => array(
            'name' => 'John Doe',
        ),
        'link' => array(
            'rel' => 'self',
            'href' => 'http://some-host.tld/articles',
        ),
        'id' => 'http://some-host.tld/some/link',
        'updated' => '2014-01-10',
        'category1' => 'Articles',
        'category2' => array(
            'term' => 'Life & stuff',
            'scheme' => 'http://some-host.tld/category/3',
            'label' => 'Life & stuff'
        ),
        'rights' => 'John & Jane (c) 2014',
        'entry-1' => array(
            'title' => 'This is so title',
            'link' => '/articles/1',
            'id' => 'http://some-host.tld/articles/1',
            'published' => 'tomorrow',
            'updated' => '1 min ago',
            'content' => 'Content of article'
        ),
        'entry_2' => array(
            'title' => 'This is a second entry title',
            'link' => '/articles/2',
            'id' => 'http://some-host.tld/articles/2',
            'updated' => '2 min ago',
            'summary' => 'Summary of article'
        ),
        'entry3' => array(
            'title' => 'Let\'s talk about atom',
            'link' => '/articles/3',
            'id' => 'http://some-host.tld/articles/3',
            'updated' => '3 min ago',
            'category' => 'From Jane',
            'content' => array(
                'type' => 'html',
                '<div>Content with some <i>html</i> <b>markup</b>.</div>',
            ),
            'author' => array(
                'name' => 'Jane Doe',
                'email' => '[email protected]'
            )
        )
    ))
;

var_dump($feed->validate());

echo $feed;

RSS 2.0 example

<?php

require 'vendor/autoload.php';

use Anh\FeedBuilder\FeedBuilder;

$feed = new FeedBuilder();

$feed
    ->setType('rss')
    ->fromArray(array(
        'title' => 'Another feed title',
        'link' => '/some/link',
        'pubDate' => 'yesterday',
        'category' => 'Another & category',
        'cloud' => '',
        'copyright' => '(c) 2014',
        'image' => array(
        ),
        'skipDays' => array(
            'day1' => 'Monday',
            'day2' => 'Tuesday'
        ),
        'skipHours' => array(
            'hour1' => 10,
            'hour2' => 11,
            'hour3' => 12
        ),
        'textInput' => array(
        ),
        'ttl' => '60',
        'item' => array(
            'title' => 'Item title',
            'link' => '/item/link',
            'guid' => array(
                '/some/guid',
                'isPermaLink' => 'no'
            ),
            'pubDate' => '2 days ago',
            'description' => 'Item description'
        ),
        'item2' => array(
            'title' => 'This is second item'
        )
    ))
;

var_dump($feed->validate());

echo $feed;

feed-builder's People

Contributors

hilobok avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.