收藏
回答

多人音视频通话接口 wx.joinVoIPChat签名问题?

多人音视频对话 用的是这两个接口wx.joinVoIPChat 和组件 voip-room。

1、在调用过程中一直提示这个错误

joinVoIPChat:fail: -10088, -10, join room failed. errType: 4, errCode: -12020, errMsg: invalid signature, -1

2、这个接口是免费试用的吗

服务端签名(php)

$data[] = "自己的appid";
$data[] = 'grop_ooo00_tests';//测试房间  这个groupId  需要生成唯一的  使用这个id 签名的人员进入都会进入一个实时语音房间
$data[] =  getNonceStr();
$data[] =  time();

sort($data,5); //
$st = implode('',$data); //拼接成一个字符串

$hash = hash_hmac('sha256', $st,$session_key); //通过 sha256

接口权限已经开通了

最后一次编辑于  2020-11-17
回答关注问题邀请回答
收藏

4 个回答

  • 杨利龙
    杨利龙
    2021-03-23

    function curl_get_https($url)

    {

        $curl = curl_init(); // 启动一个CURL会话

        curl_setopt($curl, CURLOPT_URL, $url);

        curl_setopt($curl, CURLOPT_HEADER, 0);

        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查

        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, true);  // 从证书中检查SSL加密算法是否存在

        $tmpInfo = curl_exec($curl);     //返回api的json对象

        //关闭URL请求

        curl_close($curl);

        return $tmpInfo;    //返回json对象

    }


    $appid = "wxxxxxx";

            $appsecret = "c32526c8af5be2eeaxxxsxxxxxx";

            $code = input('code''');

            $getInfoUrl = "https://api.weixin.qq.com/sns/jscode2session?appid={$appid}&secret={$appsecret}&js_code={$code}&grant_type=authorization_code";

            $info = curl_get_https($getInfoUrl);

            $info = json_decode($info,true);

            if(!$info['session_key'])

                $this->ajax(202,'session_key  errors');

                 

            $groupId = 'grop_ooo00_tests';

            $nonceStr = 'fdjkhdkhghwei7887438==';

            $timeStamp = time();

            $data = [

                'appid' => $appid,

                'groupId' => $groupId,

                'nonceStr' => $nonceStr,

                'timeStamp' => $timeStamp

            ];

            sort($data,5); //这里是个坑  php sort 的默认参数不会把数字进行字典排序  相关参数请自行查看php文档

            $st = implode('',$data); //拼接成一个字符串

            $signature = hash_hmac('sha256'$st,$info['session_key']); //通过 sha256 加密


    2021-03-23
    有用 1
    回复
  • 哪吒的小迷弟
    哪吒的小迷弟
    2021-12-09

    我也这个问题,最终是检查sor按照键名排序了,应该按照键值排序。

    2021-12-09
    有用
    回复
  • HG
    HG
    2021-02-25

    请问你是怎么解决签名的问题呢?

    2021-02-25
    有用
    回复
  • ruinb0w
    ruinb0w
    2020-11-17

    接口在小程序后台开通后就可以用了

    2020-11-17
    有用
    回复 12
    • fn
      fn
      2020-11-17
      您好,后台接口权限已经开通了。我这个签名写法有问题吗
      2020-11-17
      回复
    • ruinb0w
      ruinb0w
      2020-11-17回复fn
      你跑一下下面的示例, 看看结果是否一样
      https://developers.weixin.qq.com/minigame/dev/guide/open-ability/voip-chat.html#%E7%94%B3%E8%AF%B7%E5%BC%80%E9%80%9A
      如果一样, 检查一下这几个参数
      appId 小游戏的 appId
      groupId 游戏房间的唯一标识,由游戏自己保证唯一
      nonceStr 随机字符串,长度应小于 128
      timeStamp 生成这个随机字符串的 UNIX 时间戳(精确到秒)
      2020-11-17
      1
      回复
    • fn
      fn
      2020-11-17
      我是普通的小程序,普通的小程序能用这个接口吧?
      2020-11-17
      回复
    • ruinb0w
      ruinb0w
      2020-11-17回复fn
      只要能开通就应该能用, 不能用的话下面开关是灰色的
      2020-11-17
      回复
    • fn
      fn
      2020-11-17回复ruinb0w
      这个方法可以,发现了问题,我的php签名没问题,渲染的时候出了问题。
      2020-11-17
      回复
    查看更多(7)
登录 后发表内容
问题标签