Twilio 聊天:错误用户在加入私人频道时不是频道成员
Twilio Chat: Error User not member of channel while joining a private channel
我正在开发 1:1 聊天应用程序。在启动应用程序之前,我使用 PHP 服务器创建私人频道。频道创建正确。
用户令牌已生成,聊天客户端也已正确创建。我看到服务中也创建了用户。
加入私密频道时报错
code:50400 message:"User not member of channel" status: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);
})
});
它显示消息 'Connecting....',然后因错误而停止。
PHP代码:
$client = new Client("sid", "token");
$channel = $client->chat->services("serviceid")->channels
->create(array('friendlyName' => $friendlyName, 'uniqueName' => $uniqueName, 'type' => 'private'));
此处为 Twilio 开发人员布道师。
当您创建私人频道时,无法在那个阶段定义允许谁进入频道。来自 the documentation:
Private Channels are not visible to Users that have not been invited or added to them. Private Channel Members can only be added by other Members with sufficient permissions, or via the REST API as controlled by your business logic.
因此,为了让用户加入私人频道,您需要:
让我知道这是否有意义
我正在开发 1:1 聊天应用程序。在启动应用程序之前,我使用 PHP 服务器创建私人频道。频道创建正确。
用户令牌已生成,聊天客户端也已正确创建。我看到服务中也创建了用户。
加入私密频道时报错
code:50400 message:"User not member of channel" status: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);
})
});
它显示消息 'Connecting....',然后因错误而停止。
PHP代码:
$client = new Client("sid", "token");
$channel = $client->chat->services("serviceid")->channels
->create(array('friendlyName' => $friendlyName, 'uniqueName' => $uniqueName, 'type' => 'private'));
此处为 Twilio 开发人员布道师。
当您创建私人频道时,无法在那个阶段定义允许谁进入频道。来自 the documentation:
Private Channels are not visible to Users that have not been invited or added to them. Private Channel Members can only be added by other Members with sufficient permissions, or via the REST API as controlled by your business logic.
因此,为了让用户加入私人频道,您需要:
让我知道这是否有意义