Package Data | |
---|---|
Maintainer Username: | coolcodemy |
Maintainer Contact: | fikri@runcloud.io (Ahmad Fikrizaman Bin Abd Rahim) |
Package Create Date: | 2017-01-18 |
Package Last Update: | 2017-01-20 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:00:24 |
Package Statistics | |
---|---|
Total Downloads: | 57 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
This package implements a PHP wrapper to work with http://www.yourmembership.com/company/api-reference/
Require this package with composer by adding the following to your composer file:
"require": {
"coolcodemy/yourmembership-laravel-api": "^0.0.1"
},
Then run composer update
to download the package.
Or use
composer require coolcodemy/yourmembership-laravel-api
After updating composer, add the service provider to the providers
array in config/app.php
CoolCodeMY\YourMembershipLaravelAPI\YourMembershipServiceProvider::class,
Publish the config for the package
php artisan vendor:publish --provider="CoolCodeMY\YourMembershipLaravelAPI\YourMembershipServiceProvider"
Fill in your API_KEY, SECRET_API_KEY and SA_PASSCODE inside config/yourmembership-laravel-api.php
.
<?php
...
use CoolCodeMY\YourMembershipLaravelAPI\YMLA;
class YourController extends Controller {
public function index(YMLA $ymla)
{
// Array results
$result = $ymla->call('Auth.Authenticate', [
'Username' => 'email@examle.com',
'Password' => 'password',
])->toArray();
// JSON/Object result
$result = $ymla->call('Auth.Authenticate', [
'Username' => 'email@examle.com',
'Password' => 'password',
])->toJson();
// XML result
$result = $ymla->call('Auth.Authenticate', [
'Username' => 'email@examle.com',
'Password' => 'password',
])->toXML();
}
...
}
You don't need to generate session for authentication as this package will do it for you. The SessionID is saved inside Laravel cache for 15 minutes.
This will return the results as XML and set the return header to XML for the browser to properly print valid XML.
...
$result = $ymla->call('Auth.Authenticate', [
'Username' => 'email@examle.com',
'Password' => 'password',
])->toXML();
return response()->xml($result);
...