1. Go to this page and download the library: Download jlorente/opentok-laravel 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/ */
jlorente / opentok-laravel example snippets
// new session
$session = OpentokApi::createSession();
$sessionId = $session->getSessionId();
// check if it's been created or not (could have failed)
if (empty($sessionId)) {
throw new \Exception("An open tok session could not be created");
}
// use the necessary files
use Tomcorbett\OpentokLaravel\Facades\OpentokApi;
use OpenTok\Role;
use OpenTokException;
// get your API key from config
$api_key = Config::get('opentok.api_key');
// then create a token (session created in previous step)
try {
// note we're create a publisher token here, for subscriber tokens we would specify.. yep 'subscriber' instead
$token = OpentokApi::generateToken($sessionId,
array(
'role' => Role::PUBLISHER
)
);
} catch(OpenTokException $e) {
// do something here for failure
}
// pass these to your view where you're broadcasting from as you'll need them...
return View::make('your/view')
->with('session_id', $sessionId)
->with('api_key', $api_key)
->with('token', $token)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.