Edit File: LiveVideoService.php
<?php namespace App\Services\LiveVideo; use Illuminate\Support\Facades\DB; use Vonage\Client; use Vonage\Client\Credentials\Keypair; use Vonage\Video\MediaMode; class LiveVideoService { private $apiKey, $apiSecret, $private_key_string, $application_id,$credentials; public function __construct() { $this->apiKey = config('vonage.api_key'); $this->apiSecret = config('vonage.api_secret'); $this->private_key_string = config('vonage.private_key_string'); $this->application_id = config('vonage.application_id'); $this->credentials = new Keypair($this->private_key_string, $this->application_id); } public function createTokenForLiveAuction() { DB::beginTransaction(); try { $client = new Client($this->credentials); $vonageVideoClient = $client->video(); $session = $vonageVideoClient->createSession(); $sessionId = $session->getSessionId(); $token = $vonageVideoClient->generateClientToken($sessionId); DB::commit(); return [ 'key' => 'success', 'msg' => '', 'data' => [ 'api_key' => $this->apiKey, 'session_id' => $sessionId, 'token' => $token, 'api_secret' => $this->apiSecret, 'application_id' => $this->application_id ] ]; } catch (\Exception $e) { DB::rollback(); return ['key' => 'fail', 'msg' => $e->getMessage(), 'data' => []]; } } }
Back to File Manager