Custom RSS Reader enabled import custom image field + REST Services build with Silex micro-framework
Demo
If you want to try the output of this REST Server, you can test by yourself at http://silex.7sabores.com/timeline/rest/covers.
Download
$ git clone git@github.com:enzolutions/silex-rss-importer-image-field.git silex_rss_importer
Install
Composer
Execute inside the clone folder the command
$ cd silex_rss_importer
$ composer install
The command above will download silex mini-framework and RSS Client library.
For information about how to install composer go to https://github.com/composer/composer
Dependencies
All installed by Composer
- Silex (http://silex.sensiolabs.org)
- RSSClient (https://github.com/desarrolla2/RSSClient)
- YamlConfigServiceProvider (https://github.com/deralex/YamlConfigServiceProvider)
- dbal (https://github.com/doctrine/dbal
Features
- RSS Importer with Image support
- DB storage for imported items
- REST GET Method to fetch items in JSON format with optional date filters
- Implemented a custom RSS Processor to enable custom imagen field
- Implementd a custom RSS Parses to enable custom image field (not enabled)
Install
Use the file in config/setting.yml.dist to create your own version of setting and name the file settings.yml.
Check the settings sample file
database:
driver: pdo_mysql
host: localhost
dbname: time_closeup
user: root
password: root
charset: utf8
rss:
url: 'http://lightbox.time.com/category/closeup/feed/'
- Created a DB and put credentials in config/settings.yml
- Configure your webservices to point to web folder as document root
For quick test you can go to web folder and run php -S localhost:8000, after that just write localhost:8000 in your browser.
Usage
RSS Import : Access URL http://localhost:8000/rss/import REST JSON GET:
All Items : http://localhost:8000/rest/covers
Filters: http://localhost:8000/rest/covers/2014-04-01/2014-04-25
Enable CORS
If you are planning use this REST server as source of data for other domains you must to enable the requestor or open for any requestor. The function to acomplish that feature is at the end of web/index.php
$app->after(function (Request $request, Response $response) {
//$response->headers->set('Access-Control-Allow-Origin', '*');
$response->headers->set('Access-Control-Allow-Origin', 'http://localhost:8081');
});