Giter Club home page Giter Club logo

restfulapis's Introduction

RESTful APIs для modx revolution

Готовые конгтроллеры для работы с товарами, категориями minishop2 а так же с обычными ресурсами

Для начала работы необходимо скопировать папку rest в корневую директорию и прописать следующие:

для NGINX

server {
    ...........
    location /rest/ {
            try_files $uri @modx_rest;
    }
    location @modx_rest {
            rewrite ^/rest/(.*)$ /rest/index.php?_rest=$1&$args last;
    }
    ...........
}

После чего перезапустить веб-сервер

service nginx restart

Для Apache

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ rest/index.php?_rest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ rest/index.php [QSA,NC,L]

Опубликованные методы

Запросы для получения данных

Список товаров http://restfulapis.bustep.ru/rest/products

Список категорий http://restfulapis.bustep.ru/rest/categories

Список ресурсов http://restfulapis.bustep.ru/rest/resources

Дополнительно добавлена функция для удобного просмотра результатов в json формате. Для этого вам необходимо в конце url дописать print=1 http://restfulapis.bustep.ru/rest/resources?print=1

Получите вот такой результат

{
    "results": [
        {
            "id": 1,
            "pagetitle": "Главная",
            "longtitle": "",
            "description": "",
            "parent": 0,
            "introtext": null,
            "content": "{include 'file:resources/main.tpl'}",
            "menuindex": 0,
            "page_url": "http://restfulapis.bustep.ru/"
        },
        {
            "id": 7,
            "pagetitle": "Страница не найдена",
            "longtitle": "",
            "description": "",
            "parent": 5,
            "introtext": null,
            "content": "{include 'file:resources/service/error404.tpl'}",
            "menuindex": 1,
            "page_url": "http://restfulapis.bustep.ru/error404"
        }
    ],
    "total": 2
}

Чтобы получить полную информацию о ресурсе, можно указать ID ресурса

http://restfulapis.bustep.ru/rest/products/1

restfulapis's People

Contributors

webnitros avatar

Watchers

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.