Download the PHP package playlyfe/playlyfe without Composer
On this page you can find all versions of the php package playlyfe/playlyfe. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download playlyfe/playlyfe
More information about playlyfe/playlyfe
Files in playlyfe/playlyfe
Package playlyfe
Short Description This is the official OAuth 2.0 PHP client SDK for the Playlyfe API
License
Homepage http://github.com/playlyfe/playlyfe-php-sdk
Informations about the package playlyfe
Playlyfe PHP SDK
This is the official OAuth 2.0 PHP client SDK for the Playlyfe API.
It supports the client_credentials
and authorization code
OAuth 2.0 flows.
For a complete API Reference checkout Playlyfe Developers for more information.
Note: Breaking Changes this is the new version of the sdk which uses the Playlyfe api v2 by default if you still want to use the v1 api you can do that so by passing a version param with 'v1'
Examples
The Playlyfe class allows you to make rest api calls like GET, POST, .. etc For api v2
There is also a blog series on using this SDK here https://blog.playlyfe.com/gamify-moodle-laying-the-base/
And an easy way to run the examples in the examples folder is using docker-moodle like this,
Then navigate to http://localhost:3000/examples/client.php
Requires
PHP >= 5.5.9
libcurl3
Install
Add this to your composer.json file
Using
Create a client
If you haven't created a client for your game yet just head over to Playlyfe and login into your account, and go to the game settings and click on client
1. Client Credentials Flow
In the client page select Yes for both the first and second questions
2. Authorization Code Flow
In the client page select yes for the first question and no for the second
3. Custom Login Flow using JWT(JSON Web Token)
In the client page select no for the first question and yes for the second
This is used to create jwt token which can be created when your user is authenticated. This token can then be sent to the frontend and or stored in your session. With this token the user can directly send requests to the Playlyfe API as the player.
Client Scopes
Your client has certain access control restrictions. There are 3 kind of resources in the Playlyfe REST API they are,
1./admin
-> routes for you to perform admin actions like making a player join a team
2./design
-> routes for you to make design changes programmatically
3./runtime
-> routes which the users will generally use like getting a player profile, playing an action
The resources accessible to this client can be configured to have a read permission that means only GET
requests will work.
The resources accessible to this client can be configured to have a write permission that means only POST
, PATCH
, PUT
, DELETE
requests will work.
The version restriction is only for the design resource and can be used to restrict the client from accessing any version of the game design other than the one specified. By default it allows all.
If access to a route is not allowed and then you make a request to that route then you will get an error like this,
Documentation
You can initiate a client by giving the client_id and client_secret params
In development the sdk caches the access token in memory so you don't need to provide the store and retrieve lambdas. But in production it is highly recommended to persist the token to a database. It is very simple and easy to do it with redis. You can see the test cases for more examples.
API
Get
Post
Patch
Put
Delete
Get Login Url
Exchange Code
Read Image
Upload Image
Errors
A is thrown whenever an error occurs in each call.The Exception contains a name and message field which can be used to determine the type of error that occurred.
Faqs?
1. I get this error access_token_invalid for every request?
You are most probably appending the query params to your'e route like this
$pl.post("/runtime/actions/:action_id/play?player_id=Johny", [], []);
and this will cause the issue.
Please use the second param for your query params like this
$pl.post("/runtime/actions/:action_id/play", ["player_id" => "Johny"], []);
License
Playlyfe PHP SDK
http://dev.playlyfe.com/
Copyright(c) 2013-2014, Playlyfe IT Solutions Pvt. Ltd, [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
All versions of playlyfe with dependencies
ext-curl Version *