# Paykickstart API
## Fetching webinars:
Send a post request to http://yourdomain.com/wp-admin/admin-post.php with the following input fields:
```
name="action" value="pk_fetch_webinars"
name="verfication_code" value="verification-code-generated-in-paykickstart"
```
### example to generate verification code
The verification code must be generated by Paykickstart and then be included in the post so that the
Webinarignition plugin can verify that the request is valid.
Note: $secret_key is the webinarignition license key
```php
function generate_verification_code($post_data, $secret_key) {
$paramStrArr = array();
$paramStr = NULL;
foreach ($post_data as $key=>$value)
{
// Ignore if it is encrypted key
if ($key == "verification_code") continue;
if (!$key || !$value) continue;
$paramStrArr[] = (string) $value;
}
ksort( $paramStrArr, SORT_STRING );
$paramStr = implode("|", $paramStrArr);
$encKey = hash_hmac( 'sha1', $paramStr, $secret_key );
return $encKey;
}
```
### the request will return a json string like this:
```json
{
"message": "success",
"webinars": {
"1": {
"webinar_id": "1",
"webinar_type": "live",
"in_past": false,
"has_replay_video": true,
"webinar_title": "Test Live Webinar",
"webinar_date": "05-26-2017",
"webinar_start_time": "13:00",
"webinar_timezone": "Africa/johannesburg",
"webinar_host": "Jeandre, Mr Test"
},
"5": {
"webinar_id": "5",
"webinar_type": "evergreen",
"schedule_type": "fixed",
"fixed_timezone": "Africa/Johannesburg",
"fixed_date": "01-03-2017",
"fixed_time": "15:00 ",
"webinar_title": "Test Title",
"webinar_date": "AUTO",
"webinar_host": "Jeandre"
}
}
}
```
or:
```
{
"status": "failed",
"message": "invalid request"
}
```
or:
```
{
"message": "There are no webinars"
}
```
## Registering user for a webinar
Note: a registration email will automatically be sent to the "buyer_email"
### Live webinar:
Send a post request to http://yourdomain.com/wp-admin/admin-post.php with the following input fields:
```
name="action" value="pk_register_webinar"
name="webinar_id" value="the-webinar-id e.g. 1"
name="name" value="person fullname"
name="buyer_email" value="buyer@emailaddress.com"
name="verification_code" value="generate-the-verification-code"
name="webinar_type" value="live"
```
### Evergreen webinar:
Send a post request to http://yourdomain.com/wp-admin/admin-post.php with the following input fields:
```
name="action" value="pk_register_webinar"
name="webinar_id" value="the-webinar-id e.g. 1"
name="name" value="person fullname"
name="buyer_email" value="buyer@emailaddress.com"
name="verification_code" value="generate-the-verification-code"
name="webinar_type" value="evergreen"
name="evergreen_start_date" value="01-30-2017 format mm-dd-yyyy paykickstart member needs to supply this
name="evergreen_start_time" value="13:30" format hh:mm paykickstart member needs to supply this
name="schedule_type" value="fixed" // at this point it should always be "fixed"
name="timezone" value="e.g. africa/johannesburg"
```
### Possible responses
```
{
"status": "success",
"message": "user has been registered for webinar"
}
```
or:
```
{
"status": "failed",
"message": "email address is already registered"
}
```
or:
```
{
"status": "failed",
"message": "invalid request"
}
```