Register an Account
Update time: 2022/11/25 08:08:00
Registering an account
This API is used to import your accounts in the current application into the CommsEase IM system and create the IDs (accid) in the CommsEase system so that IM features are available.
A basic account registration and initial login process is shown in the following diagram:
IM-SDK is integrated in the application client such as iOS, Android, and Web. Your app server hosts your application workloads. IM Server is managed by CommsEase.
Note: If an account is registered, CommsEase Server returns the accid and token. You can manage the accid and token on the app server.
Request URL
POST https://api-sg.netease.im/nimserver/user/create.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8
Request parameters
-
For information about headers in the POST request, see Overview.
-
The POST request body contains the following parameters:
Parameter | Type | String upper limit | Required | Example | Description |
accid | String | 32 | Yes | "123456" | CommsEase account must be unique. If letters are involved, make sure they are in lower case when passing parameters. Only use letters, numbers, half-width underscore (_), @, half-width dot (.), and half-width (-). Please make sure the accid is consistent with that in the result returned by this interface. |
token | String | 128 | Optional | "abcdef" | Login key (token) for user account. If no token is specified, CommsEase automatically generates one and returns it upon successful creation. |
name | String | 64 | Optional | "zhangsan" | User profile name |
props | String | 1024 | Optional | {"k":"v"} | This parameter is no longer recommended for use. |
icon | String | 1024 | Optional | "https://netease/xxx.png" | User profile picture URL |
sign | String | 256 | Optional | "Hello World" | User signature |
String | 64 | Optional | "xxx@163.com" | User email | |
birth | String | 16 | Optional | "xxxx-xx-xx" | User birthday |
mobile | String | 32 | Optional | "+852-xxxxxxxx" | User's mobile, country code (for example, United States: +1-xxxxxxxxxx) or area code (for example, Hong Kong: +852-xxxxxxxx) is required for any mobile number registered outside of Mainland China. |
gender | int | / | Optional | 2 | User gender, 0-unknown, 1-male, 2-female. Other figures would result in parameter error. |
ex | String | 1024 | Optional | {"level":1} | User profile extension fields, recommended to be encapsulated into JSON. |
Parameter | Type | Example | Description |
code | int | 200 | Status code |
info | String | { "name": "zhangsan", "accid": "123456", "token": "abcdef" } |
Information returned upon successful registration |
desc | String | "already register" | Information returned upon un-successful registration |
Example
Request example (curl)
curlcurl -X POST -H "AppKey: go9***3mgq3" -H "Nonce: 4t***23t23t" -H "CurTime: 1443592222" -H "CheckSum: 9e9db3b***583f86" -H "Content-Type: application/x-www-form-urlencoded" -d 'accid=123456&name=zhangsan' 'https://api-sg.netease.im/nimserver/user/create.action'
Request example (Java)
todo
Success response
json"Content-Type": "application/json; charset=utf-8"
{
"code": 200,
"info": {
"name": "zhangsan",
"accid": "123456",
"token": "abcdef"
}
}
Error response
json"Content-Type": "application/json; charset=utf-8"
{
"code": 414,
"desc": "already register"
}
Error code
Error codes may be returned in the body of HTTP responses. For more information, see Error codes.