Secure video player for any PHP site

Whether your site uses a framework or plain PHP, one curl request gets a token and puts the secure player in your lesson page.

Why XAPlayer for PHP

  • Any PHP code

    Plain PHP, CodeIgniter, Yii, Symfony or anything else: all it takes is one HTTP request.

  • Download protection

    Video streams encrypted, and downloaded files won’t play without the student’s device key.

  • User name as watermark

    The name and phone you send move across the picture.

  • Only on your domain

    The player only appears on domains you list in the panel.

Three steps to secure playback

  1. Create an API key and add your domain.
  2. After checking the user’s access, get a token with curl.
  3. Put the returned URL in an iframe.

Tutorials and docs

A taste of the code

The full code, where it goes and how to test it are in the tutorial.

watch.php
$ch = curl_init('https://en.xaplayer.ir/api/v1/embed-tokens');
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('XAPLAYER_API_KEY'),
                         'Content-Type: application/json'],
  CURLOPT_POSTFIELDS => json_encode([
    'courseId' => 'COURSE_ID',
    'viewer' => ['id' => (string) $userId, 'name' => $userName],
  ]),
]);
$url = json_decode(curl_exec($ch), true)['url'];

Questions

Any version with curl and json_encode.

Yes, as long as the host allows outgoing HTTPS requests.

A token, a url ready for an iframe, and its lifetime in seconds.

Status codes 400, 401, 404 and 429 are listed in the API reference with causes and fixes.

Other platforms

Protect your course today

Signing up takes two minutes. 14 days free, with 10 licenses on us.

Start your 14-day free trial