我正在开发一个1:1的聊天应用程序。我在启动应用程序之前使用PHP服务器创建专用通道。通道正确创建。
用户令牌已经生成,聊天客户端也正确创建。我看到用户也是在服务中创建的。
加入私人频道时,会抛出错误。
代码:50400消息:"用户不是频道成员"状态:403
Javascript代码:
Twilio.Chat.Client.create(token,clientOptions).then(client => {
chatClient = client;
showMessage('Connecting.....');
chatClient.getChannelBySid(channelid)
.then(function(chosenChannel) {
showMessage('Joining Chat.....');
myChannel=chosenChannel;
joinChannel();
})
.catch(function(err) {
console.log(err);
})
});
它会显示消息'正在连接....'然后因错误而停止。
PHP代码:
$client = new Client("sid", "token");
$channel = $client->chat->services("serviceid")->channels
->create(array('friendlyName' => $friendlyName, 'uniqueName' => $uniqueName, 'type' => 'private'));
答案 0 :(得分:1)
Twilio开发者传道者在这里。
当您创建私人频道时,无法在该阶段定义谁可以进入频道。来自the documentation:
未邀请或添加到其中的用户看不到私人频道。私有渠道成员只能由具有足够权限的其他成员添加,或者通过业务逻辑控制的REST API添加。
因此,为了让用户加入私人频道,您需要:
让我知道这是否有意义