每当我尝试生成令牌 致命错误时,我都会收到此错误:在...中找不到“类”角色
可能是我错过任何依赖。
的config.php
<?php
require_once('vendor/autoload.php');
use OpenTok\OpenTok;
use OpenTok\Session;
use OpenTok\Role;
$key= 123455;
$secret='87643gri8y98643kjg49874';
$present_session ='jhvh5489754kb54089u43r398y5';
$opentok = new OpenTok($key,$secret);
?>
getToken.php
<?php
include('config.php');
$token = $opentok->generateToken('pjijirtolnpjr', array(
'data' => json_encode(array(
'name' => 'oihohtr'
)),
'role' => Role::SUBSCRIBER
));
echo $token;
?>
app.js
$(document).ready(function(){
var presenceSession = OT.initSession(45319022, '1_MX40NTMxOTAyMn5-MTQ0MTYyMzM3ODg2Mn4zTHBxOUZKOFBhdzc1bnk0OEVvMlozY3h-UH4');
if(presenceSession.sessionId){
$.get('getToken.php',function(data,status){
console.log(data);
});
}
});
答案 0 :(得分:0)
试试这个
<?php
include('config.php');
use OpenTok\Session;
use OpenTok\Role;
$token = $opentok->generateToken('pjijirtolnpjr', array(
'data' => json_encode(array(
'name' => 'oihohtr'
)),
'role' => Role::SUBSCRIBER
));
echo $token;
?>