1

I am trying to make a chat sandboxing api, aka creating the user, channel and adding the user to the channel. The problem is that every time i call the restApi to create a new user, it doesn't take the attributes or the friendlyName. The code is the following:

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

Thanks.

Adrian
  • 33
  • 4

1 Answers1

2

Twilio developer evangelist here.

Your code to create the user isn't quite right there. create takes the identity as the first argument and then the optional arguments in an array as the second. Try this instead:

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

Let me know if that helps at all.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • Yes, that seemed to be the problem. I was looking at the documentation on the website and it only contained the identity for PHP and i corelated that with Node and the rest and i thought it all had to be in the array. Thanks. – Adrian Mar 13 '18 at 11:00
  • Why in the HE DOUBLE HOCKEY STICKS is this not mentioned in the documentation? Up-voted! – josh May 21 '18 at 04:28