用户
提示
本篇文档有视频教程,请点击这里查看
#
1. 用户授权登陆client.authorizeToken(code);
返回值
{ "access_token": "user authorization token", "scope": "list of permissions that the user has given, e.g. 'PROFILE:READ ASSETS:READ'"}
提示
- 这里的 code 获取,需要客户端完成授权操作。 点击这里查看客户端端代码 。
- 如果初始化
client
的时候,携带了client_secret
,就只需要传入code
参数即可。 - 如果没有,则需要传入第二个参数
client_secret
。 - 获取到的
access_token
可以访问对应scope
的接口。具体内容请查看这里
#
2. 获取用户信息client.userMe();
返回值
{ "type": "user", "user_id": "d419d2b0-5c20-4dd7-9a5c-177375c249b8", "identity_number": "7000104117", "phone": "d419d2b0-5c20-4dd7-9a5c-177375c249b8", "full_name": "node-sdk-test123", "biography": "https://mixin.one/authhttps://mixin.one/authhttps://mixin.one/auth", "avatar_url": "", "relationship": "ME", "mute_until": "0001-01-01T00:00:00Z", "created_at": "2021-08-25T07:18:48.207247252Z", "is_verified": false, "is_scam": false, "app": { "type": "app", "app_id": "d419d2b0-5c20-4dd7-9a5c-177375c249b8", "app_number": "7000104117", "redirect_uri": "https://mixin.one/auth", "home_uri": "https://mixin.one", "name": "node-sdk-test", "icon_url": "", "description": "https://mixin.one/authhttps://mixin.one/authhttps://mixin.one/auth", "capabilities": ["CONTACT", "GROUP"], "resource_patterns": ["https://mixin.one/"], "category": "OTHER", "creator_id": "105f6e8b-d249-4b4d-9beb-e03cefaebc37", "updated_at": "2021-08-27T01:47:18.941742117Z", "app_secret": "", "capabilites": ["CONTACT", "GROUP"] }, "session_id": "7412bbcd-218d-43f6-a9a7-46e10ff0021a", "pin_token": "", "pin_token_base64": "", "code_id": "4a4049bb-2733-4751-bbff-46f90a51f204", "code_url": "https://mixin.one/codes/4a4049bb-2733-4751-bbff-46f90a51f204", "device_status": "", "has_pin": true, "has_emergency_contact": false, "receive_message_source": "EVERYBODY", "accept_conversation_source": "EVERYBODY", "accept_search_source": "EVERYBODY", "fiat_currency": "USD", "transfer_notification_threshold": 0, "transfer_confirmation_threshold": 100}
提示
- 如果是机器人调用,则会返回
app
字段。否则没有 - 如果是机器人调用,
phone
字段和user_id
一样
#
3. 获取多个用户信息client.readUsers(['e8e8cd79-cd40-4796-8c54-3a13cfe50115']);
返回值
[ { "type": "user", "user_id": "e8e8cd79-cd40-4796-8c54-3a13cfe50115", "identity_number": "30265", "phone": "", "full_name": "刘泽美", "biography": "欢迎交流 Mixin 机器人开发问题。", "avatar_url": "https://mixin-images.zeromesh.net/OsaSpGZMBV4PmQ2Om-UnDZ-878Bk37heqprakp_Sll6MWM-ciLdUQrvEDIeSF4z3t0sgfXt8Hw4zmDkiR2irag0=s256", "relationship": "STRANGER", "mute_until": "2020-08-27T10:11:57.481232553Z", "created_at": "2017-11-27T05:10:36.311323157Z", "is_verified": false, "is_scam": false }]
提示
注意这里只能用 user_id
来查询。
user_id
或 identity_number
获取单个用户信息#
4. 根据 client.readUser('30265');client.readUser('e8e8cd79-cd40-4796-8c54-3a13cfe50115');
返回值
{ "type": "user", "user_id": "e8e8cd79-cd40-4796-8c54-3a13cfe50115", "identity_number": "30265", "phone": "", "full_name": "刘泽美", "biography": "欢迎交流 Mixin 机器人开发问题。", "avatar_url": "https://mixin-images.zeromesh.net/OsaSpGZMBV4PmQ2Om-UnDZ-878Bk37heqprakp_Sll6MWM-ciLdUQrvEDIeSF4z3t0sgfXt8Hw4zmDkiR2irag0=s256", "relationship": "STRANGER", "mute_until": "2020-08-27T10:11:57.481232553Z", "created_at": "2017-11-27T05:10:36.311323157Z", "is_verified": false, "is_scam": false}
提示
- 用
identity_number
查询的时候,有访问频率限制。频繁请求会被服务器拒绝。 - 用
user_id
查询没有频率限制。
identity_number
或 phone
获取单个用户信息#
5. 根据 client.searchUser('30265');client.searchUser('+8617700000000');
返回值
{ "type": "user", "user_id": "e8e8cd79-cd40-4796-8c54-3a13cfe50115", "identity_number": "30265", "phone": "", "full_name": "刘泽美", "biography": "欢迎交流 Mixin 机器人开发问题。", "avatar_url": "https://mixin-images.zeromesh.net/OsaSpGZMBV4PmQ2Om-UnDZ-878Bk37heqprakp_Sll6MWM-ciLdUQrvEDIeSF4z3t0sgfXt8Hw4zmDkiR2irag0=s256", "relationship": "STRANGER", "mute_until": "2020-08-27T10:11:57.481232553Z", "created_at": "2017-11-27T05:10:36.311323157Z", "is_verified": false, "is_scam": false}
提示
此接口有访问频率限制。频繁请求会被服务器拒绝。
#
6. 授权其他机器人授权其他机器人,获得 authorization_code
以完成其他机器人的授权。
client.getAuthorizeCode({ client_id: `f6deb534-13bd-45f0-9b34-0d618827f500`, scopes: ['PROFILE:READ'], // pin: '',}); // 参数为要授权的机器人的 client_id
提示
此方法需要 pin
,如果构建 client
的时候,没有传入的话,此方法可以传入 pin
返回值
{ "type": "authorization", "authorization_id": "5fbc7e9c-63c2-47a7-9565-05817d580ac0", "authorization_code": "599fd289cffe4xxxxxxxxxxxxxx63b6d33c3ac551bd2845ddd9b81dd44c75016", "scopes": [ "PROFILE:READ" ], "code_id": "24491ebe-9992-4f02-85ec-a374a2e005d5", "app": { "type": "app", "app_id": "f6deb534-13bd-45f0-9b34-0d618827f500", "app_number": "7000103988", "redirect_uri": "https://cnb.mixinbots.com/auth", "home_uri": "https://cnb.mixinbots.com/", "name": "CNB超级社群", "icon_url": "https://mixin-images.zeromesh.net/Aplananzgr4Txcks0b7MvC3azIUG4eTbcHigM4QUe1yFbrI5HbabutOp2l8W-CLej5zCwA7d6wGxkNK7QDFJEf1pD7XMxIuFfUZF=s256", "description": "CNB( chui niu bi ),娱乐、开心、最牛的币圈生活调味剂😁", "capabilities": [ "CONTACT", "GROUP", "IMMERSIVE", "ENCRYPTED" ], "resource_patterns": [ "https://cnb.mixinbots.com/" ], "category": "SOCIAL", "creator_id": "6ac866ba-d55e-4fcd-a416-5547fc709e07", "updated_at": "2022-06-09T08:59:54.25097973Z", "is_verified": false, "capabilites": [ "CONTACT", "GROUP", "IMMERSIVE", "ENCRYPTED" ] }, "user": { "type": "user", "user_id": "11efbb75-e7fe-44d7-a14f-698535289310", "identity_number": "7000100180", "phone": "", "full_name": "开发专用", "biography": "devdevdevdevdevdevdevdevdevdevdevdevdevdevdevdevdevdevdevdev", "avatar_url": "", "relationship": "", "mute_until": "0001-01-01T00:00:00Z", "created_at": "2018-05-13T03:59:22.547773979Z", "is_verified": false, "is_scam": false, "code_id": "", "code_url": "", "app": { "type": "app", "app_id": "11efbb75-e7fe-44d7-a14f-698535289310", "app_number": "7000100180", "redirect_uri": "http://192.168.50.160:8000/auth", "home_uri": "http://192.168.50.160:8000", "name": "开发专用", "icon_url": "", "description": "devdevdevdevdevdevdevdevdevdevdevdevdevdevdevdevdevdevdevdev", "capabilities": [Array], "resource_patterns": [Array], "category": "SOCIAL", "creator_id": "e8e8cd79-cd40-4796-8c54-3a13cfe50115", "updated_at": "2022-06-20T06:43:10.651056638Z", "is_verified": false, "app_secret": "", "session_secret": "", "capabilites": [Array] } }, "created_at": "2022-12-28T10:36:42.039192156Z", "accessed_at": "0001-01-01T00:00:00Z"}