Twilio Chat用户创建friendlyName

时间:2018-03-12 11:09:56

标签: twilio twilio-php twilio-programmable-chat

我正在尝试聊天沙盒api,即创建用户,频道并将用户添加到频道。问题是每次我调用restApi来创建一个新用户时,它都不会使用属性或friendlyName。代码如下:

$user->chat->services($serviceSid)->users->create(
        array(
            'identity'     => $identity,
            'friendlyName' => $friendlyName,
            'attributes'   => $attributes,
            'roleSid'      => $roleSid
        )
    );

感谢。

1 个答案:

答案 0 :(得分:2)

Twilio开发者传道者在这里。

您创建用户的代码并不完全正确。 create将标识作为第一个参数,然后将数组中的可选参数作为第二个参数。试试这个:

$user->chat->services($serviceSid)->users->create(
    $identity,
    array(
        'friendlyName' => $friendlyName,
        'attributes'   => $attributes,
        'roleSid'      => $roleSid
    )
);

让我知道这是否有帮助。