Giter VIP home page Giter VIP logo

web_service's Introduction

Web Service for TYPO3 CMS

This is an extension for TYPO3 CMS aiming to query data in a flexible way. Possible output format: JSON, Atom, RSS.

The URLs given as example are encoded.

# Return all FE user group
http://domain.tld/content/usergroups

# Return all FE users - authentication required
http://domain.tld/content/users

# Return latest FE users login - authentication required
http://domain.tld/content/last-login

# Return one FE user with id "1"
http://domain.tld/content/users/1

# Return the frontend group related to user "1" (no yet implemented!!)
http://domain.tld/content/users/1/groups

Five output format are supported: atom, csv, html, json, xml. JSON is the default

# Configure the output format - atom, csv, html, json, xml
http://domain.tld/content/users.xml

Under the hood, the URL is decoded and corresponds to something like::

http://domain.tld/index.php?eID=web_service&route=users/1;

The Web Service is meant for retrieving data and is read-only and will consequently (at least for now) not provide PUT, POST, DELETE, PATCH methods.

Configuration

The configuration is done via TypoScript. For a new content type you must register a new key like "users" or "usergroups" as used in the URL http://domain.tld/content/users.

plugin.tx_webservice {
    settings {

        mappings {

            # Required key for a new content type
            users {

                # Required value!
                tableName = fe_users

                # Tell the maximum items taken by default for the list.
                limit = 50

                # Optional default filters (not yet implemented)
                filter =

                # Protect the output with a token or a user session
                permissions {

                    # Possible comma separated list of Frontend User group.
                    frontendUserGroups = *

                    # Give a general uuid token to protect this data stream
                    #token = 3ce2b796-69cd-11e6-8b77-86f30ca893d3
                }

                # The fields being display in the list.
                # http://domain.tld/content/users
                many {
                    fields = uid, first_name, last_name
                }

                # The fields being display in the detail.
                # http://domain.tld/content/users/1
                one {
                    fields = uid, first_name, last_name, usergroup
                }
            }

            last-login < .users
            last-login {

                # Default ordering which will override the "default_sortby" in the TCA
                orderings {
                    lastlogin = DESC
                }

                # Tell the maximum items taken by default for the list.
                limit = 10
            }

            # Stream frontend user group information
            usergroups {

                # Required value!
                tableName = fe_groups

                # In this example we take every fields of fe_groups excpect those ones
                excludedFields = felogin_redirectPid, tx_extbase_type, TSconfig, lockToDomain, subgroup

                # Default ordering which will override the "default_sortby" in the TCA
                orderings {
                    title = ASC
                }

            }
        }

        # Specific configuration for format "atom". In this case we really want to limit the number of items.
        atom {
            limit = 10
        }
    }
}

Installation

  1. Install via composer or clone the extension into /path/typo3conf/ext/.

    $ composer require fab/web-service

  2. Go to Extension Manager and activate the extension web_service.

  3. Add a rewrite rule to your .htaccess:

    RewriteRule ^content/(.*)$ /index.php?eID=web_service&route=$1 [QSA,L]

or, if you are using Nginx:

rewrite ^/content/(.*)$ /index.php?eID=web_service&route=$1 last;

Now you can start fetching content with content/.

web_service's People

Contributors

fabarea avatar powerkiki avatar

Watchers

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