集成用户体系,指将您的用户的环信username和password,以及昵称等信息写入网页插件,以便用户发起咨询时,能够在环信客服云识别对应的用户。
执行以下步骤:
配置示例:
<script src='//kefu.easemob.com/webim/easemob.js'></script><script>window.easemobim = window.easemobim || {}; easemobim.config = { configId: '304fe7b6-3046-416b-b169-0398f647b90e', // 用户所在的 appKey 需要与 configId 中指定的关联的 appKey 一致 user: { // username 必填,password 和 token 任选一项填写 username: 'webim-test-user', password: 'GQWWERP46V', token: 'YWMtzGo52JaqEeeELnmPrOc5h15sv_A0eRHkoOT3YpQCxx70JPTKiW4R56U-k0L6lDp3AwMAAAFebzmSdABPGgCyzGooJgc5V4LBxr0TtaAsXQld8naV_3qc-8GEDDMAHw' }, // 访客信息(可选) visitor: { trueName: '黎小冷', qq: '12345678', phone: '18812345678', companyName: '环信', userNickname: '小冷', description: '意向客户', email: 'xiaoleng@easemob.com' } }</script>
获取用户Token:根据username和password获取access_token。
Request body:
{ "grant_type":"password", "username":"user", "password":"pwd"}
Response示例
{ "access_token": "YWMtI5JsbKhHEem57CF4KOxCxnljbbBGLhHpjpSjqzuD_CB4YttqkNER6YIJEZ8gpOpaAwMAAAFr_hTkLQBPGgB7xNZ6-mjCRkn_nivCNcB01uiyS9Yt9pdiU_6LH579zA", "expires_in": 5184000, "user": { "uuid": "7862db6a-90d1-11e9-8209-119f20a4ea5a", "type": "user", "created": 1560756495382, "modified": 1560765534117, "username": "test1", "activated": true, "device_token": "Getg6CgqFanQ4dwAvn9/qxoa5crWpNSkiVFcVt3eDr1S6xqz5X2sm0dbi1yNAQsl", "notifier_name": "2882303761517507836" } }
注意:
参数解释:
参数 | 类型 | 必选 | 描述 |
---|---|---|---|
configId | String | 是 | 设置为您的网页插件页面显示的configId的值 |
user | Object | 否 | 用户信息,用于集成用户体系 |
visitor | Object | 否 | 访客信息 |