Tutorial 1.1: SVOD Web application - the base


Within this first SVOD tutorial, you will learn the basic steps that will help you to understand the process of setting up a simple and powerful application. Make sure you are familiar with the introduction section: Understanding the API, especially with the chapter that covers the "Main integration points".

This tutorial covers how to:

  1. Prepare a subscription plan using the Cleeng Dashboard
  2. Add the "Buy button" on your website
  3. Validate entitlements and grant access



1. Prepare subscription plan using UI

Make sure you have a publisher account (if not, here is the link: Publisher registration).

Go to the dashboard and create a new subscription offer here: subscription section This setup is documented in detail in our FAQ section: Setting up a subscription (step 1 only).

2. Add "Buy button" on your website

See Buy button code snippet documentation.

Grab this code directly from the subscription section in the Cleeng Dashboard by clicking on the "code" column.

After the Buy button is placed on your website you, are ready to start selling your subscription. Take a look at the first graph in the previous tutorial: Understanding the API.

3. Validate access

The validation of user entitlements to a subscription offer , is very straightforward. For security reasons this validation need to happen server-side using the method getAccessStatus. The response of this method (true or false) defines if you can show the premium content. Mostly it defines the page or application to return via two different versions:

  • Users who cannot see the content as visitor is new on your website or the subscription expired (getAccessStatus returns false)
  • Users who can see the content as visitor has active subscription (getAccessStatus returns true)

Below the two most popular use-cases are detailed out:


1. Global flow (SVOD Demo case)

Main assumption is to have a separate url for those who can't access the content. To be more specific, see example of our SVOD demo. We have two versions of the website, under two different urls:

No-access Url: http://svod-demo.cleeng.com/, which is the perfect place to show:

  • Buy Button
  • All the rules connected with subscription
  • Login option

Access Url: http://svod-demo.cleeng.com/premium-content

This is the place where all you content should be placed. Only for customers with active subscription.

Logic behind this is very simple. When customer with access granted wants to enter No-access Url, we redirect him to Access Url. And the other way around, customer without access tries to enter Access Url, we redirect him to No-access Url.

Se below the part of code from SVOD Demo responsible for such redirect: HomePageAction.php

    if ($this->cleengApi->isAccessGranted('A764667811_NL')) {
        return new RedirectResponse('/premium-content');
    }


2. Single-page flow

All the pages with videos are open for all visitors. Only the part of each page is blocked for non-subscribers, most likely the part is simply the player code.

    if ($this->cleengApi->isAccessGranted('A764667811_NL')) {
        echo "video player code";
    } else {
        echo "customer doesn't have access, you can display buy button code"
    }