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.

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

报告相同问题?

悬赏问题

  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改