承接 sule/api 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sule/api

Composer 安装命令:

composer require sule/api

包简介

Helper to create APIs in Laravel.

README 文档

README

Base library to start creating API using Laravel Framework. Plus support OAuth 2 authorization.

Installation

1. Composer

Open your composer.json file and add the following lines:

{
    "require": {
        "sule/api": "2.0.0",
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "git@github.com:feelinc/laravel-api.git",
            "options": {
                "ssl": {
                    "verify_peer": "false"
                }
            }
        }
    ]
    "minimum-stability": "stable"
}e

Run composer update from the command line

composer update

2. Service Provider & Aliases

Add the following to the list of service providers in "app/config/app.php".

'Sule\Api\ApiServiceProvider',

Add the following to the list of aliases in "app/config/app.php".

'API'             => 'Sule\Api\Facades\API'

3. Create Tables

Create all required tables from "TABLES.sql" file.

4. Configuration

After installing, you can publish the package's configuration file into your application, by running the following command:

php artisan config:publish sule/api

Routes

POST /authorization

Request Headers

User-Agent: My User Agent 
Content-MD5: md5($stringContent.$clientSecret) 

Request Body

grant_type:    client_credentials 
client_id:     JXSb6nEzpQ0e3WAWjsSsZurCaLy0knDjzkwxRlJs 
client_secret: C4vpZLRI2kncfXJQZ9l0hdnaTCTupyqF1deCVEPf 

Response Body

{
    "access_token": "jU5vKEBSPSVqRwEXwjIM0N1YefCG0hwqTK5i0UC3",
    "token_type": "bearer",
    "expires": 1399017374,
    "expires_in": 3600
}

Filters

1. api.oauth

Check route againts authorized client and passed scope, in example checking current client is having "read" scope:

Route::get('api/v1/users', array(
    'before' => array(
        'api.oauth:read'
    ), function() {

    }
));

2. api.content.md5

Check request content signature at "Content-MD5" header. Signature should be md5($stringContent.$clientSecret)

Route::post('api/v1/users', array(
    'before' => array(
        'api.content.md5', 
        'api.oauth:write'
    ), function() {

    }
));

3. api.ua.required

Check request "User-Agent" header.

Route::post('api/v1/users', array(
    'before' => array(
        'api.ua.required', 
        'api.content.md5', 
        'api.oauth:write'
    ), function() {

    }
));

4. api.limit

Check request not exceed the limit per each client.

Route::post('api/v1/users', array(
    'before' => array(
        'api.ua.required', 
        'api.content.md5', 
        'api.limit', 
        'api.oauth:write'
    ), function() {

    }
));

Response

Return JSON response including Limiter and Access-Control-Expose-Headers header

1. Single JSON object

return API::resourceJson($data = array(), $status = 200, array $headers = array());

2. Collection JSON object

return API::collectionJson($data = array(), $status = 200, array $headers = array());

统计信息

  • 总下载量: 39
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2014-05-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固