I have a PHP project and its structure is as follows:
The main folder is called OpenTok, inside it there are two files, the index.php and the composer.json and another folder also called OpenTok that includes all the files in the package. The problem is that when I try to generate a session in the following way, it sends me an error:
<?php
use OpenTok\OpenTok;
$apiObj = new OpenTok($API_KEY, $API_SECRET);
$session = $apiObj->createSession(array('mediaMode' => MediaMode::ROUTED));
echo $session->getSessionId();
?>
The error you send me is the following:
Fatal error: Class 'OpenTok \ OpenTok' not found in C: \ xampp \ htdocs \ OpenTok \ index.php on line 4
I hope and can help me find a solution. Greetings.
Adding more information, the composer.json I have is the following:
{
"name": "Opentok/Opentok",
"description": "OpenTok is a platform for creating real time streaming video applications, created by TokBox.",
"type": "library",
"keywords": [
"TokBox",
"OpenTok",
"PHP",
"WebRTC",
"video",
"streaming"
],
"homepage": "https://github.com/opentok/Opentok-PHP-SDK",
"license": "MIT",
"authors": [
{
"name": "Ankur Oberoi",
"email": "[email protected]",
"role": "Developer"
},
{
"name": "Community contributors",
"homepage": "https://github.com/opentok/Opentok-PHP-SDK/graphs/contributors"
}
],
"support": {
"email": "[email protected]",
"issues": "https://github.com/opentok/Opentok-PHP-SDK/issues"
},
"require": {
"php": ">=5.0.0",
"guzzle/guzzle": "~3.7",
"aoberoi/json-works": "~1.0",
"firebase/php-jwt": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "~4.1",
"phing/phing": "dev-master"
},
"autoload": {
"psr-4": {
"OpenTok\": "src/OpenTok"
}
}
}