Download the PHP package lukapeharda/kourses-php without Composer
On this page you can find all versions of the php package lukapeharda/kourses-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lukapeharda/kourses-php
More information about lukapeharda/kourses-php
Files in lukapeharda/kourses-php
Informations about the package kourses-php
Kourses PHP bindings
The Kourses PHP library provides access to Kourses API from applications written in PHP. It includes a pre-defined set of classes for API resources such as members
, memberships
and permissions
.
Requirements
PHP 5.6.0 and later.
Installation
You can install the library via Composer. Run the following command:
To use the library, use Composer's autoload:
Getting Started
Visit Kourses Settings / API keys page and generate API key. Each key is tied to only one of your website. Copy your API key as you won't be able to access the token later on.
API key should go in HTTP Authorization
header as a bearer token:
First initialize a client and set the token
If you want to access beta environment of Kourses app, use setApiBaseUrl
method to change the URL:
Fetching memberships
To fetch all published memberships use memberships
resource and the all
method:
Returned data will be paginated (default number of memberships per page is 100). In order to change number of memberships per page or current page use page
and per_page
params (respectively):
You can iterate over $memberships
to get KoursesPhp\Membership
entities.
There are several helpful methods to handle pagination:
Creating members
Use create
method on the members
resource:
If member was found (based on their email address) they will be updated with the rest of the given data.
You may set a list of memberships
for which the member should get access to in the same API call:
Sending activation email
By default, when new member is created they will be sent an activation email.
To disable this set send_activation_notification
to 0
:
Setting permission expiry dates
For each membership you can set future expiry date using memberships_ends_at
param or nested memberships[0][ends_at]
. Date given needs to be in YYYY-MM-DD
or YYYY-MM-DD hh:mm:ss
format:
Skipping drip schedule
For each membership you can disable drip schedule using memberships_skip_drip_schedule
param or nested memberships[0][skip_drip_schedule]
:
By default it will honor the set drip schedule.
Running membership's email integrations
For each membership you can enable running of email integrations using memberships_run_email_integrations
param (or nested memberships[0][run_email_integrations]
):
Fetching allowed memberships for a member
Use memberMemberships
resource and all
method to fetch a list of all memberships that member was granted access to:
You can even use member's email address to fetch the memberships:
Returned data will be paginated (default number of memberships per page is 100). In order to change number of memberships per page or current page use page
and per_page
params (respectively):
Generate one-click login link for a member
Use memberLoginLink
resource and its create
method to generate temporary signed login link.
Returned $loginLink
object will have a login_link
property which you can serve to your user in order for them to log in. expires_at
property which holds the timestamp (ISO-8601) then the login link will expire.
Signed link will expired in 5 mins (300 seconds).
You can even use member's email address to generate the link:
If you wish to redirect the member after successful login specify a redirect
param with relative path:
Grant a permission
To grant a permission you need to call create
method on permissions
resource and provide a member ID (or their email address) and a membership ID:
You can add and extra ends_at
param to specify permission expiry date. Date given needs to be in YYYY-MM-DD
or YYYY-MM-DD hh:mm:ss
format:
If you wish to skip drip schedule set for a given membership use skip_drip_schedule
and set it to 0
:
If you wish to run email integrations for a given membership use run_email_intgrations
and set it to 1
:
By default the set drip schedule will be honored.
Revoke a permission
To revoke a permission you need to call delete
method on permissions
resource and provide a member ID (or their email address) and a membership ID:
You can add and extra ends_at
param to specify permission expiry date. Date given needs to be in YYYY-MM-DD
or YYYY-MM-DD hh:mm:ss
format:
Documentation
Check out examples folder for some basic use cases. Full documentation is available on developer.kourses.com.
All versions of kourses-php with dependencies
guzzlehttp/guzzle Version 6.3.*|6.5.*|^7.2
illuminate/support Version ~5.5|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0