PHP code example of lukapeharda / kourses-php
1. Go to this page and download the library: Download lukapeharda/kourses-php library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lukapeharda / kourses-php example snippets
$kourses = new KoursesPhp\Client();
$kourses->setApiKey('GENERATED_API_TOKEN');
$kourses->setApiBaseUrl('https://app.kourses-beta.com/api/');
$memberships = $kourses->memberships->all();
$memberships = $kourses->memberships->all([
'per_page' => 10,
'page' => 2,
]);
$memberships->getCurrentPage(); // returns current page number
$memberships->getLastPage(); // returns last page number
$memberships->getTotal(); // returns total number of memberships
$memberships->getFrom(); // returns current page items range start
$memberships->getTo(); // returns current page items range end
$memberships->getPerPage(); // returns number of memberships per page
$member = $kourses->members->create([
'email' => '[email protected] ',
'first_name' => 'John',
'last_name' => 'Doe',
]);
$member = $kourses->members->create([
'email' => '[email protected] ',
'first_name' => 'John',
'last_name' => 'Doe',
'memberships' => ['MEMBERSHIP#1', 'MEMBERSHIP#2'],
]);
// or
$member = $kourses->members->create([
'email' => '[email protected] ',
'first_name' => 'John',
'last_name' => 'Doe',
'memberships' => [
[
'id' => 'MEMBERSHIP#1'
], [
'id' => 'MEMBERSHIP#2'
]
],
]);
$member = $kourses->members->create([
'email' => '[email protected] ',
'first_name' => 'John',
'last_name' => 'Doe',
'send_activation_notification' => 0,
]);
$member = $kourses->members->create([
'email' => '[email protected] ',
'first_name' => 'John',
'last_name' => 'Doe',
'memberships' => ['MEMBERSHIP#1', 'MEMBERSHIP#2'],
'memberships_ends_at' => [
'MEMBERSHIP#1' => '2030-04-05',
],
]);
// or
$member = $kourses->members->create([
'email' => '[email protected] ',
'first_name' => 'John',
'last_name' => 'Doe',
'memberships' => [
[
'id' => 'MEMBERSHIP#1',
'ends_at' => '2030-04-05'
], [
'id' => 'MEMBERSHIP#2'
]
],
]);
$member = $kourses->members->create([
'email' => '[email protected] ',
'first_name' => 'John',
'last_name' => 'Doe',
'memberships' => ['MEMBERSHIP#1', 'MEMBERSHIP#2'],
'memberships_skip_drip_schedule' => [
'MEMBERSHIP#1' => 0,
],
]);
// or
$member = $kourses->members->create([
'email' => '[email protected] ',
'first_name' => 'John',
'last_name' => 'Doe',
'memberships' => [
[
'id' => 'MEMBERSHIP#1',
'skip_drip_schedule' => 0
], [
'id' => 'MEMBERSHIP#2'
]
],
]);
$member = $kourses->members->create([
'email' => '[email protected] ',
'first_name' => 'John',
'last_name' => 'Doe',
'memberships' => ['MEMBERSHIP#1', 'MEMBERSHIP#2'],
'memberships_run_email_integrations' => [
'MEMBERSHIP#1' => 1,
],
]);
// or
$member = $kourses->members->create([
'email' => '[email protected] ',
'first_name' => 'John',
'last_name' => 'Doe',
'memberships' => [
[
'id' => 'MEMBERSHIP#1',
'run_email_integrations' => 1
], [
'id' => 'MEMBERSHIP#2'
]
],
]);
$memberships = $kourses->memberMemberships->all([
'member' => 'MEMBER#1',
]);
$memberships = $kourses->memberMemberships->all([
'member' => '[email protected] ',
]);
$memberships = $kourses->memberMemberships->all([
'member' => 'MEMBER#1',
'per_page' => 10,
'page' => 2,
]);
$loginLink = $koures->memberLoginLink->create([
'member' => 'MEMBER#1',
]);
$loginLink = $kourses->memberLoginLink->create([
'member' => '[email protected] ',
]);
$loginLink = $kourses->memberLoginLink->create([
'member' => '[email protected] ',
'redirect' => 'account/profile',
]);
$status = $kourses->permissions->create([
'member' => 'MEMBER#1',
'membership' => 'MEMBERSHIP#1',
]);
$status = $kourses->permissions->create([
'member' => 'MEMBER#1',
'membership' => 'MEMBERSHIP#1',
'ends_at' => '2030-04-05',
]);
$status = $kourses->permissions->create([
'member' => 'MEMBER#1',
'membership' => 'MEMBERSHIP#1',
'skip_drip_schedule' => 0,
]);
$status = $kourses->permissions->create([
'member' => 'MEMBER#1',
'membership' => 'MEMBERSHIP#1',
'run_email_intgrations' => 0,
]);
$status = $kourses->permissions->delete([
'member' => 'MEMBER#1',
'membership' => 'MEMBERSHIP#1',
]);
$status = $kourses->permissions->delete([
'member' => 'MEMBER#1',
'membership' => 'MEMBERSHIP#1',
'ends_at' => '2030-04-05',
]);
bash
composer