@@ -113,7 +113,7 @@ public function getProfile($userId = null)
113113 }
114114 $ userId = $ this ->data ['user_id ' ];
115115 }
116- return $ this ->matrix ()->request ('GET ' , $ this ->endpoint ('profile/ ' .$ userId ));
116+ return $ this ->matrix ()->request ('GET ' , $ this ->endpoint ('profile/ ' .urlencode ( $ userId) ));
117117 }
118118
119119 /**
@@ -132,7 +132,7 @@ public function getAvatar($userId = null)
132132 }
133133 $ userId = $ this ->data ['user_id ' ];
134134 }
135- return $ this ->matrix ()->request ('GET ' , $ this ->endpoint ('profile/ ' .$ userId .'/avatar_url ' ));
135+ return $ this ->matrix ()->request ('GET ' , $ this ->endpoint ('profile/ ' .urlencode ( $ userId) .'/avatar_url ' ));
136136 }
137137
138138 /**
@@ -147,7 +147,7 @@ public function setAvatar($avatarUrl)
147147 {
148148 if ($ this ->check ()) {
149149 $ userId = $ this ->data ['user_id ' ];
150- return $ this ->matrix ()->request ('PUT ' , $ this ->endpoint ('profile/ ' .$ userId .'/avatar_url ' ), [
150+ return $ this ->matrix ()->request ('PUT ' , $ this ->endpoint ('profile/ ' .urlencode ( $ userId) .'/avatar_url ' ), [
151151 'avatar_url ' => $ avatarUrl
152152 ], [
153153 'access_token ' => $ this ->data ['access_token ' ]
@@ -172,7 +172,7 @@ public function getDisplayName($userId = null)
172172 }
173173 $ userId = $ this ->data ['user_id ' ];
174174 }
175- return $ this ->matrix ()->request ('GET ' , $ this ->endpoint ('profile/ ' .$ userId .'/displayname ' ));
175+ return $ this ->matrix ()->request ('GET ' , $ this ->endpoint ('profile/ ' .urlencode ( $ userId) .'/displayname ' ));
176176 }
177177
178178 /**
@@ -187,7 +187,7 @@ public function setDisplayName($displayName)
187187 {
188188 if ($ this ->check ()) {
189189 $ userId = $ this ->data ['user_id ' ];
190- return $ this ->matrix ()->request ('PUT ' , $ this ->endpoint ('profile/ ' .$ userId .'/displayname ' ), [
190+ return $ this ->matrix ()->request ('PUT ' , $ this ->endpoint ('profile/ ' .urlencode ( $ userId) .'/displayname ' ), [
191191 'displayname ' => $ displayName
192192 ], [
193193 'access_token ' => $ this ->data ['access_token ' ]
@@ -204,16 +204,21 @@ public function setDisplayName($displayName)
204204 */
205205 public function register ($ username , $ password )
206206 {
207- $ data = $ this -> matrix ()-> request ( ' POST ' , $ this -> endpoint ( ' register ' ), [
207+ $ userData = [
208208 'auth ' => [
209209 'type ' => 'm.login.dummy '
210210 ],
211- 'bind_email ' => true ,
212- 'bind_msisdn ' => true ,
211+ 'bind_email ' => false ,
212+ 'bind_msisdn ' => false ,
213213 'password ' => $ password ,
214- 'username ' => $ username ,
215- 'x_show_msisdn ' => true
216- ], [
214+ 'x_show_msisdn ' => false
215+ ];
216+
217+ if ($ username ) {
218+ $ userData ['username ' ] = $ username ;
219+ }
220+
221+ $ data = $ this ->matrix ()->request ('POST ' , $ this ->endpoint ('register ' ), $ userData , [
217222 'kind ' => 'user '
218223 ]);
219224 $ this ->setData ($ data );
0 commit comments