24 | This is a sample web service for use with OpenTok. See the OpenTok
25 |
26 | learning-opentok-php repo on GitHub.
27 |
28 |
31 |
32 | GET /session |
33 | Return an OpenTok API key, session ID, and token. |
34 |
35 |
36 | GET /room/:name |
37 | Return an OpenTok API key, session ID, and token associated with a room name. |
38 |
39 |
40 | POST /archive/start |
41 | Start an archive for the specified OpenTok session. |
42 |
43 |
44 | POST /archive/:archiveId/stop |
45 | Stop the specified archive. |
46 |
47 |
48 | GET /archive/:archiveId/view |
49 | View the specified archive. |
50 |
51 |
52 | GET /archive/:archiveId |
53 | Return metadata for the specified archive. |
54 |
55 |
56 | GET /archive |
57 | Return a list of archives. More Information |
58 | Pagination is enabled by applying either count or offset parameteres. |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/templates/join.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | OpenTok Getting Started
4 |
5 |
6 |
7 |
8 |
9 |
13 |
14 |
59 |
60 |
--------------------------------------------------------------------------------
/templates/view.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | View Archive
7 |
8 |
9 |
10 | Waiting for the archive...
11 | This page will refresh until the archive status is available.
12 |
13 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/web/.htaccess:
--------------------------------------------------------------------------------
1 | RewriteEngine On
2 |
3 | RewriteCond %{REQUEST_FILENAME} !-f
4 | RewriteRule ^ index.php [QSA,L]
5 |
6 |
--------------------------------------------------------------------------------
/web/index.php:
--------------------------------------------------------------------------------
1 | load();
30 | } catch (InvalidPathException $e) {
31 | // No-op, user is allowed to set things via a real environment variable as well
32 | }
33 |
34 |
35 | // PHP CLI webserver compatibility, serving static files
36 | $filename = __DIR__.preg_replace('#(\?.*)$#', '', $_SERVER['REQUEST_URI']);
37 | if (php_sapi_name() === 'cli-server' && is_file($filename)) {
38 | return false;
39 | }
40 |
41 | $builder = new ContainerBuilder();
42 | $builder->addDefinitions(__DIR__ . '/../config/global.php');
43 | AppFactory::setContainer($builder->build());
44 | $app = AppFactory::create();
45 |
46 | $app->get('/', IndexAction::class)->setName('index');
47 | $app->get('/session', SessionAction::class)->setName('session');
48 | $app->get('/room/{name}', RoomAction::class)->setName('room');
49 | $app->get('/room/{name}/join', JoinAction::class)->setName('room.join');
50 | $app->get('/archive', ListAction::class)->setName('archive.list');
51 | $app->map(['GET', 'POST'], '/archive/start', StartAction::class)->setName('archive.start');
52 | $app->map(['GET', 'POST'], '/archive/{archiveId}', GetAction::class)->setName('archive.get');
53 | $app->map(['GET', 'POST'], '/archive/{archiveId}/stop', StopAction::class)->setName('archive.stop');
54 | $app->map(['GET', 'POST'], '/archive/{archiveId}/view', ViewAction::class)->setName('archive.view');
55 |
56 | // return HTTP 200 for HTTP OPTIONS requests
57 | $app->options('/:routes+', function(RequestInterface $request, ResponseInterface $response) {
58 | return $response;
59 | });
60 | $app->add(function (RequestInterface $request, $handler) use ($app) {
61 | $response = $handler->handle($request);
62 | return $response
63 | ->withHeader('Access-Control-Allow-Origin', '*')
64 | ->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization')
65 | ->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS')
66 | ;
67 | });
68 |
69 | $app->run();
70 |
--------------------------------------------------------------------------------