Package Data | |
---|---|
Maintainer Username: | lhj1982 |
Maintainer Contact: | lhj1982@gmail.com (Huajun Li) |
Package Create Date: | 2015-05-19 |
Package Last Update: | 2016-09-23 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 15:04:07 |
Package Statistics | |
---|---|
Total Downloads: | 257 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 3 |
Total Open Issues: | 0 |
Should include all core modules and functions for different applications
Add the following line to the require
section of composer.json
:
{
"require": {
"ademes/core": "dev-master"
}
}
'Ademes\Core\CoreServiceProvider',
to the service provider list in app/config/app.php
.In order to use the Api Proxy publish its configuration first
php artisan config:publish ademes/core
Afterwards edit the file app/config/packages/ademes/core/core.php
to suit your needs.
$authResponse = $app['authClient']->authenticate('admin@admin.com', '000000', 'IhzopIc5SuMf3oUT', 'GUXaqBpeFgN1GKYNTOvh4nOnRpEig4J1');
if ($authResponse) {
Session::set('AuthToken', $authResponse);
} else {
throw new Exception('You\'re not authenticated');
}
$user = $app['userClient']->getLoggedInUser($authResponse->getAccessToken());
if ($user) {
Session::put('data.user', $user);
}
Use this class for all request to api services.
Client has 3 methods:
$query = $this->http->get($_ENV['API_VERSION'].'/companies', [
'query' => [
'access_token' => Session::get('AuthToken')->getAccessToken()
]
]);
$data = [
'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
'body' => [
'name' => Input::get('name'),
'description' => Input::get('description'),
'url' => Input::get('url'),
'photo' => fopen($path, 'r'),
'access_token' => Session::get('AuthToken')->getAccessToken()
]
];
$response = $this->http->post($_ENV['API_VERSION'] . '/companies', $data);
$body = ['access_token'=>Session::get('AuthToken')->getAccessToken()];
$response = $this->http->delete($_ENV['API_VERSION'] . '/companies/' . $id, ['body'=>$body]);
$data = [
'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
'body' => [
'_method' => 'PUT',
'name' => Input::get('name'),
'description' => Input::get('description'),
'url' => Input::get('url'),
'access_token' => Session::get('AuthToken')->getAccessToken()
]
];
$response = $this->http->post($_ENV['API_VERSION'] . '/companies/'.$id, $data);