2017 © Pedro Peláez
 

library parse-rss

This PHP library can easily parse xml files, especially RSS1.0, RSS2.0 and ATOM.

image

yuzuru-s/parse-rss

This PHP library can easily parse xml files, especially RSS1.0, RSS2.0 and ATOM.

  • Monday, January 30, 2017
  • by s1130125
  • Repository
  • 3 Watchers
  • 5 Stars
  • 7,460 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 453 % Grown

The README.md

This PHP library can easily parse xml files, especially RSS1.0, RSS2.0 and ATOM.

Coverage Status Build Status Stable Version Download Count License, (*1)

This parser can handle RSS easily without being conscious of the difference of RSS1.0 and RSS2.0 and ATOM. and gets the minimum necessary value., (*2)

  1. site name
  2. site url
  3. article title
  4. article url
  5. article description
  6. date that article posted
  7. thumbnail of article

This thumbnail is composed by og:img and img tags included description., (*3)

Requirements

  • PHP
    • >=5.5 >=5.6, >=7.0
  • ext-xml
  • ext-curl
  • Composer

Installation

  • Using composer
{
    "require": {
       "yuzuru-s/parse-rss": "1.0.*"
    }
}
$ php composer.phar update yuzuru-s/parse-rss --dev

How to use

Please check sample code, (*4)

<?php
require __DIR__ . '/../vendor/autoload.php';
use YuzuruS\Rss\Feed;

$url = 'http://blog.livedoor.jp/dqnplus/index.rdf';
$ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36';
$res = Feed::load($url, $ua, true);

echo 'Title:' . $res['channel']['title'] . "\n";
echo 'Link:' . $res['channel']['link'] . "\n";

foreach ($res['item'] as $r) {
    echo "\t" . 'Article Title:' . $r['title'] . "\n";
    echo "\t" . 'Article Description:' . $r['description'] . "\n";
    echo "\t" . 'Article Date:' . $r['date'] . "\n";
    echo "\t" . 'Article og:img:' . $r['image']['ogimg'] . "\n";
    foreach ($r['image']['img'] as $i) {
        echo "\t\t" . 'Desc:img:' . $i . "\n";
    }
}

OUTPUT

array(2) {
  'channel' =>
  array(2) {
    'title' =>
    string(27) "site name"
    'link' =>
    string "site url"
  }
  'item' =>
  array(15) {
    [0] =>
    array(5) {
      'title' =>
      string "title"
      'link' =>
      string"url"
      'date' =>
      string "date"
      'description' =>
      string "description"
      'image' =>
      array(2) {
        'ogimg' =>
        string(58) "img url"
        'img' =>
        array(3) {
          [0] =>
          string(58) "img url1"
          [1] =>
          string(58) "img url2"
          [2] =>
          string(94) "img url3"
        }
      }
    }
    [1] =>
    array(5) {
...

You can also enable caching:, (*5)

Feed::$cacheDir = __DIR__ . '/tmp';
Feed::$cacheExpire = '5 hours';

How to run unit test

Run with default setting., (*6)

% vendor/bin/phpunit -c phpunit.xml.dist

Currently tested with PHP 7.0.0, (*7)

History

  • 1.0.1
    • Bug fix
  • 1.0.0
    • Published

License

Copyright (c) 2016 YUZURU SUZUKI. See MIT-LICENSE for further details., (*8)

  • Yuzuru Suzuki
    • http://yuzurus.hatenablog.jp/

The Versions

30/01 2017

dev-master

9999999-dev https://github.com/YuzuruS/parse-rss

This PHP library can easily parse xml files, especially RSS1.0, RSS2.0 and ATOM.

  Sources   Download

MIT

The Requires

 

The Development Requires

parser atom rss rdf

30/01 2017

1.0.6

1.0.6.0 https://github.com/YuzuruS/parse-rss

This PHP library can easily parse xml files, especially RSS1.0, RSS2.0 and ATOM.

  Sources   Download

MIT

The Requires

 

The Development Requires

parser atom rss rdf

30/01 2017

1.0.5

1.0.5.0 https://github.com/YuzuruS/parse-rss

This PHP library can easily parse xml files, especially RSS1.0, RSS2.0 and ATOM.

  Sources   Download

MIT

The Requires

 

The Development Requires

parser atom rss rdf

25/01 2017

1.0.4

1.0.4.0 https://github.com/YuzuruS/parse-rss

This PHP library can easily parse xml files, especially RSS1.0, RSS2.0 and ATOM.

  Sources   Download

MIT

The Requires

 

The Development Requires

parser atom rss rdf

25/01 2017

1.0.3

1.0.3.0 https://github.com/YuzuruS/parse-rss

This PHP library can easily parse xml files, especially RSS1.0, RSS2.0 and ATOM.

  Sources   Download

MIT

The Requires

 

The Development Requires

parser atom rss rdf

14/01 2017

1.0.2

1.0.2.0 https://github.com/YuzuruS/parse-rss

This PHP library can easily parse xml files, especially RSS1.0, RSS2.0 and ATOM.

  Sources   Download

MIT

The Requires

 

The Development Requires

parser atom rss rdf

26/11 2016

1.0.1

1.0.1.0 https://github.com/YuzuruS/parse-rss

This PHP library can easily parse xml files, especially RSS1.0, RSS2.0 and ATOM.

  Sources   Download

MIT

The Requires

 

The Development Requires

parser atom rss rdf

26/11 2016

1.0.0

1.0.0.0 https://github.com/YuzuruS/parse-rss

This PHP library can easily parse xml files, especially RSS1.0, RSS2.0 and ATOM.

  Sources   Download

MIT

The Requires

 

The Development Requires

parser atom rss