All Projects → nglasl → silverstripe-apiwesome

nglasl / silverstripe-apiwesome

Licence: BSD-3-Clause license
A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

Programming Languages

PHP
23972 projects - #3 most used programming language
CSS
56736 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to silverstripe-apiwesome

instagram-widget-by-wpzoom
The easiest way to add a nice Instagram widget on your WordPress site. It just works!
Stars: ✭ 22 (+69.23%)
Mutual labels:  feed
RSS-to-Telegram-Bot
A Telegram RSS bot that cares about your reading experience
Stars: ✭ 482 (+3607.69%)
Mutual labels:  feed
iextrading4j-hist
IEX Trading library to parse TOPS and DEEP multicast packets
Stars: ✭ 20 (+53.85%)
Mutual labels:  feed
web-front-end-rss
📙 根据 RSS 抓取最新前端技术文章,来源:前端早读课、前端大全、前端之巅、淘宝前端、张鑫旭博客、凹凸实验室等
Stars: ✭ 24 (+84.62%)
Mutual labels:  feed
dtd2mysql
MySQL / MariaDB import for DTD feeds (fares, timetable and routeing)
Stars: ✭ 25 (+92.31%)
Mutual labels:  feed
stream-net
NET Client - Build Activity Feeds & Streams with GetStream.io
Stars: ✭ 28 (+115.38%)
Mutual labels:  feed
sliver
REPL for SilverStripe, powered by Psysh. Interactively debug and tinker with a sliver of your code.
Stars: ✭ 17 (+30.77%)
Mutual labels:  silverstripe
zhangkn.github.io
新博客地址:https://kunnan.blog.csdn.net
Stars: ✭ 20 (+53.85%)
Mutual labels:  feed
FeedSDK
Java SDK for downloading large gzipped (tsv) item feed files and applying filters for curation
Stars: ✭ 20 (+53.85%)
Mutual labels:  feed
laminas-feed
Consume and generate Atom and RSS feeds, and interact with Pubsubhubbub.
Stars: ✭ 97 (+646.15%)
Mutual labels:  feed
silverstripe-mandrill
Mandrill integration for Silverstripe
Stars: ✭ 17 (+30.77%)
Mutual labels:  silverstripe
atom
Library for serializing the Atom web content syndication format https://crates.io/crates/atom_syndication
Stars: ✭ 68 (+423.08%)
Mutual labels:  feed
this-american-life-archive
Unofficial RSS feed for the podcast "This American Life" with episodes 1 to current
Stars: ✭ 19 (+46.15%)
Mutual labels:  feed
osmosfeed
Turn GitHub into an RSS reader
Stars: ✭ 839 (+6353.85%)
Mutual labels:  feed
silverstripe-cookie-consent
GDPR compliant cookie popup and consent checker
Stars: ✭ 16 (+23.08%)
Mutual labels:  silverstripe
cakephp-feed
CakePHP Plugin with RssView to create RSS feeds.
Stars: ✭ 13 (+0%)
Mutual labels:  feed
stream-python
Python Client - Build Activity Feeds & Streams with GetStream.io
Stars: ✭ 134 (+930.77%)
Mutual labels:  feed
f43.me
A more readable & cleaner feed
Stars: ✭ 60 (+361.54%)
Mutual labels:  feed
podcast-feed-parser
A highly customizable package for fetching and parsing podcast feeds into simple and manageable JavaScript objects. For use with node or in the browser.
Stars: ✭ 39 (+200%)
Mutual labels:  feed
Briefly
source based news in short : Winner @MumbaiHackathon 2018
Stars: ✭ 35 (+169.23%)
Mutual labels:  feed

apiwesome

The current release is 2.2.15

A module for SilverStripe which will automatically create customisable JSON/XML feeds for your data objects (including pages), and provides a modular security token that can be used for other applications.

Requirement

  • SilverStripe 3.0 → 3.5

This module is no longer supported.

Getting Started

  • Place the module under your root project directory.
  • Define any custom JSON/XML data object exclusions/inclusions through project configuration.
  • /dev/build
  • Select JSON/XML through the CMS.
  • Configure attribute visibility.
  • Regenerate the security token x:y
  • /apiwesome/retrieve/data-object-name/json?token=x:y
  • /apiwesome/retrieve/data-object-name/xml?token=x:y

Overview

Data Object Exclusions/Inclusions

ALL data objects are included by default (excluding some core), unless disabled or inclusions have explicitly been defined.

DataObjectOutputConfiguration::customise_data_objects('exclude', array(
	'DataObjectName'
));
DataObjectOutputConfiguration::customise_data_objects('include', array(
	'DataObjectName'
));

To completely disable the JSON/XML:

DataObjectOutputConfiguration::customise_data_objects('disabled');

Attribute Visibility Customisation

visibility

The JSON/XML feed will only be available to data objects with attribute visibility set through the CMS. Any has_one relationships may be displayed, where attribute visibility is determined recursively.

Recursive Relationships

These are enabled by default, however will greatly impact performance if many nested relationships are visible.

To disable the recursion:

Injector:
  APIwesomeService:
    properties:
      recursiveRelationships: false

Security Token

A JSON/XML feed request will require the current security token passed through, where this may be regenerated by an administrator (invalidating the previous security token).

token

The security token generation (and validation) is modular, and can still be used when the JSON/XML is completely disabled (more below):

SecurityAdmin:
  extensions:
    - 'APIwesomeTokenExtension'

Output

A JSON/XML feed request may have a number of optional filters applied, where the &filter will only apply to visible attributes:

  • &limit=5
  • &sort=Attribute,ORDER
  • &filter1=value
  • &filter2=value

It may also be previewed through the appropriate model admin of your data object.

preview

Pretty JSON

This is enabled by default, however will slightly impact performance if many nested relationships are visible.

To disable the pretty printing:

Injector:
  APIwesomeService:
    properties:
      prettyJSON: false

Developer Functionality

PHP

Accessing the service:

$service = Singleton('APIwesomeService');

The methods available may be programmatically called to generate JSON, with optional filters:

$JSON = $service->retrieve('DataObjectName', 'JSON');
$JSON = $service->retrieve('DataObjectName', 'JSON', 5, array(
	'Attribute',
	'ORDER'
), array(
	'Attribute1' => 'value',
	'Attribute2' => 'value'
));
$objects = DataObjectName::get()->toNestedArray();
$JSON = $service->retrieveJSON($objects);

XML, with optional filters:

$XML = $service->retrieve('DataObjectName', 'XML');
$XML = $service->retrieve('DataObjectName', 'XML', 5, array(
	'Attribute',
	'ORDER'
), array(
	'Attribute1' => 'value',
	'Attribute2' => 'value'
));
$objects = DataObjectName::get()->toNestedArray();
$XML = $service->retrieveXML($objects);

JSON/XML for a versioned page (though the CMS may not correctly preview XML), with regard to the respective stage in index():

return $service->retrieveStaged($this->data()->ID, 'JSON');

They may also be used to parse JSON/XML from another APIwesome instance. Therefore, this module may be used as both an API and external connector between multiple projects.

$objects = $service->parseJSON($JSON);
$objects = $service->parseXML($XML);

The security token validation (and generation) is modular, and can be used for other applications (more above):

$validation = $service->validateToken($this->getRequest()->getVar('token'));
switch($validation) {
	case APIwesomeService::VALID:

		// The token matches the current security token.

		break;
	case APIwesomeService::INVALID:

		// The token does not match a security token.

		break;
	case APIwesomeService::EXPIRED:

		// The token matches a previous security token.

		break;
}

jQuery

JSON example:

;(function($) {
	$(function() {

		$.getJSON('//ss3.1/apiwesome/retrieve/data-object-name/json?token=' + token(), function(JSON) {

			// Iterate over each data object.

			if(JSON['APIwesome'] !== undefined) {
				$.each(JSON['APIwesome']['DataObjects'], function(index, object) {

					// The JSON feed security token is no longer valid!

					if((index === 'Expired') && (object === true)) {
						return false;
					}

					// Iterate over each visible attribute.

					$.each(object, function(type, attributes) {
						$.each(attributes, function(attribute, value) {
						});
						break;
					});
				});
			}
		})

		// The JSON feed has either not yet been configured, or no data objects were found.

		.fail(function() {
		});

	});
})(jQuery);

Maintainer Contact

Nathan Glasl, [email protected]
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].