Package Data | |
---|---|
Maintainer Username: | sulaeman |
Maintainer Contact: | me@sulaeman.com (Sulaeman) |
Package Create Date: | 2014-02-11 |
Package Last Update: | 2014-12-15 |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2024-11-23 03:22:39 |
Package Statistics | |
---|---|
Total Downloads: | 38 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 12 |
Total Watchers: | 2 |
Total Forks: | 10 |
Total Open Issues: | 0 |
Base library to start creating API using Laravel Framework. Plus support OAuth 2 authorization.
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
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'
Create all required tables from "TABLES.sql" file.
After installing, you can publish the package's configuration file into your application, by running the following command:
php artisan config:publish sule/api
POST /authorization
User-Agent: My User Agent
Content-MD5: md5($stringContent.$clientSecret)
grant_type: client_credentials
client_id: JXSb6nEzpQ0e3WAWjsSsZurCaLy0knDjzkwxRlJs
client_secret: C4vpZLRI2kncfXJQZ9l0hdnaTCTupyqF1deCVEPf
{
"access_token": "jU5vKEBSPSVqRwEXwjIM0N1YefCG0hwqTK5i0UC3",
"token_type": "bearer",
"expires": 1399017374,
"expires_in": 3600
}
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() {
}
));
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() {
}
));
Check request "User-Agent" header.
Route::post('api/v1/users', array(
'before' => array(
'api.ua.required',
'api.content.md5',
'api.oauth:write'
), function() {
}
));
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() {
}
));
Return JSON response including Limiter and Access-Control-Expose-Headers header
return API::resourceJson($data = array(), $status = 200, array $headers = array());
return API::collectionJson($data = array(), $status = 200, array $headers = array());