doubei2340 2014-10-13 15:58
浏览 59
已采纳

Opentok php服务器sdk,会话和令牌无法正常工作

I need help for my Php server in opentok this is my online website that i created

mrsvideocall.bugs3.com/Engine.php

the url above gives you session and token

it has output session id and token but.. when i tried that output. the token and the session is not connecting

if you want to try you can use my apikey and api secret this was just my trial account

api key : 45007972

api secret: xxxxxxxxxxxxxxxxxxxxxxx

try it. .it wont work

I dont know why.

this the code inside my php file. .is there anything wrong?

<?php
require "vendor/autoload.php";

use OpenTok\OpenTok;
use OpenTok\Session;
use OpenTok\Role; 
use OpenTok\MediaMode;

$API_KEY = "45007972";
$API_SECRET = "xxxxxxxxxxxxxxxxxxxxxxx";
$opentok = new OpenTok($API_KEY, $API_SECRET);

// Create a session that attempts to use peer-to-peer streaming:
$session = $opentok->createSession();
$session = $opentok->createSession(array('mediaMode' => MediaMode::ROUTED ));
// Store this sessionId in the database for later use
echo $sessionId = $session->getSessionId();

// Generate a Token from just a sessionId (fetched from a database)
$token = $opentok->generateToken($sessionId);
// Generate a Token by calling the method on the Session (returned from createSession)
$token = $session->generateToken();

// Set some options in a token
echo $token = $session->generateToken(array(
'role' => Role::PUBLISHER,
'expireTime' => time()+(7 * 24 * 60 * 60), // in one week
'data' => 'name=Eleo'
));

if i just make session and token at dashboard it was working but when i tried the result of my token and session generator it does not work it has result but not working

  • 写回答

1条回答 默认 最新

  • drgweamoi473182981 2014-10-15 16:46
    关注

    I just tried the sessionId and token generated at your URL and they worked fine to connect. One caveat was that you also echo-ed a literal between the two values so I had to separate them. If you are having trouble connecting to the session, could you please share what error you are seeing and what client side code you have used?

    Also, please read through the comments in the code you copy/pasted. You are actually generating 2 sessions and 3 tokens, but only outputting one of each, so you are unnecessarily doing extra work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog