Code Monkey home page Code Monkey logo

jsonfeed's Introduction

JSONFeed

Build Status Scrutinizer Code Quality Latest Stable Version

JSONFeed is a pragmatic syndication format, like RSS and Atom, but with one big difference: it’s JSON instead of XML.

This library provides functionnalits for mananaging feed through your PHP code. It provides a natural syntax for accessing elements of feed.

Install

Install the library using composer:

{
    "require": {
        "jdecool/jsonfeed": "^0.1"
    }
}

Example

Create your feed :

use DateTime;
use DateTimeZone;
use JDecool\JsonFeed\Author;
use JDecool\JsonFeed\Feed;
use JDecool\JsonFeed\Item;

$author = new Author('Brent Simmons');
$author->setUrl('http://example.org/');
$author->setAvatar('https://example.org/avatar.png');

$item = new Item('2347259');
$item->setUrl('https://example.org/2347259');
$item->setDatePublished(new DateTime('2016-02-09 14:22:00', new DateTimeZone('+0200')));
$item->setContentText('Cats are neat. https://example.org/cats');

$feed = new Feed('Brent Simmons’s Microblog');
$feed->setUserComment('This is a microblog feed. You can add this to your feed reader using the following URL: https://example.org/feed.json');
$feed->setHomepageUrl('https://example.org/');
$feed->setFeedUrl('https://example.org/feed.json');
$feed->setAuthor($author);
$feed->addItem($item);

Render it :

use JDecool\JsonFeed\Writer\RendererFactory;

$renderer = $factory->createRenderer(RendererFactory::VERSION_1);

header('Content-Type: application/json');
echo $renderer->render($feed);

jsonfeed's People

Contributors

jdecool avatar

Watchers

James Cloos avatar Michael COULLERET 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.