用户操作

获取用户详情

接口

GET https://cloud.minapp.com/oserve/v1/miniapp/user-profile/:profile_id/

其中 :profile_id 需替换为用户 ID(已废弃)

GET https://cloud.minapp.com/oserve/v1/miniapp/user-profile/?user_id={{ user_id }}

其中 user_id 可从用户列表中获取。

info 推荐使用用户信息处理中的接口进行用户信息的获取,v1 接口已废弃。

代码示例

{% tabs curl=”Curl”, node=”Node”, php=”PHP” %}

{% content “curl”%}

  1. curl -X GET \
  2. -H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
  3. -H "Content-Type: application/json" \
  4. https://cloud.minapp.com/oserve/v1/miniapp/user-profile/?user_id=55019

{% content “node” %}

  1. var opt = {
  2. uri: 'https://cloud.minapp.com/oserve/v1/miniapp/user-profile/?user_id=4271xx', // 4271xx 对应 :user_id
  3. method: 'GET',
  4. headers: {
  5. Authorization: `Bearer ${token}`,
  6. }
  7. }
  8. request(opt, function(err, res, body) {
  9. console.log(body)
  10. })

{% content “php”%}

  1. <?php
  2. $user_id = '4271xx'; // 用户 ID
  3. $url = "https://cloud.minapp.com/oserve/v1/miniapp/user-profile/?user_id={$user_id}";
  4. $ch = curl_init();
  5. $header = array(
  6. "Authorization: Bearer {$token}",
  7. 'Content-Type: application/json; charset=utf-8'
  8. );
  9. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  10. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  11. curl_setopt($ch, CURLOPT_URL, $url);
  12. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  15. $res = curl_exec($ch);
  16. curl_close($ch);

{% endtabs %}

返回示例

  1. {
  2. "avatar": "https://media.ifanrusercontent.com/media/tavatar/55/c3/55c3dbebcc61891be10d29ded808c84a01dxxxxx.jpg",
  3. "city": "Guangzhou",
  4. "country": "China",
  5. "created_at": 1504504504,
  6. "gender": 1,
  7. "id": 550xx,
  8. "nickname": "PCG",
  9. "openid": "onzns0KsLKFyg3-VcW0GwTE6xxxx",
  10. "unionid": "onzns0KsLKFyg3-VcW0GwTE6xxxx",
  11. "province": "Guangdong",
  12. "user_group": [
  13. 137
  14. ],
  15. "user_id": 366197xx
  16. }

获取用户列表

接口

GET https://cloud.minapp.com/oserve/v1/miniapp/user-profile/

info 推荐使用用户信息处理中的接口进行用户信息的获取,v1 接口已废弃。

参数说明

参数 类型 必填 说明
created_at String N 用户创建的时间,值为时间戳。查询创建时间大于等于 2017-01-01 的用户 created_at__gte=1483228800,查询创建时间小于等于 2017-01-01 的用户:created_at__lte=1483228800
gender Number N 户的性别,其中 1 表示男,2 表示女
group String N 给定用户组 ID 查询在用户组下的用户列表。只支持 in 查询:group__in=258,360
limit Number N 限制返回资源的个数,默认为 20 条,最大可设置为 1000
nickname String N 用户的微信昵称,支持等值查询 nickname=Tom, 模糊查询 nickname__contains=Tom
offset Number N 设置返回资源的起始偏移值,默认为 0
openid String N 用户的 OpenID
order_by String N 排序(支持 created_at 进行排序)
unionid String N 用户的 UnionID
user_id String N 用户 ID (对应 _userprofile 表中的 id 字段)

代码示例

{% tabs first=”Curl”, second=”Node”, third=”PHP” %}

{% content “first” %}

  1. curl -X GET \
  2. -H "Authorization: Bearer 58f6cd9f84b1b0c04941fbd4d87bc5f14a785107" \
  3. -H "Content-Type: application/json" \
  4. -G \
  5. -d nickname__contains=Tom \
  6. -d gender=1 \
  7. -d created_at__gt=1483228800 \
  8. -d order_by=-created_at \
  9. https://cloud.minapp.com/oserve/v1/miniapp/user-profile/

{% content “second” %}

  1. var request = require('request');
  2. var opt = {
  3. uri: 'https://cloud.minapp.com/oserve/v1/miniapp/user-profile/',
  4. method: 'GET',
  5. headers: {
  6. Authorization: `Bearer ${token}`,
  7. },
  8. qs: { // query string, 被附加到uri的参数
  9. nickname__contains: 'username',
  10. gender: 1,
  11. created_at__gte: 1483228800,
  12. user_id: '363953xx',
  13. order_by: '-created_at'
  14. }
  15. }
  16. request(opt, function(err, res, body) {
  17. console.log(body)
  18. })

{% content “third”%}

  1. <?php
  2. $query_data = array(
  3. 'nickname__contains' => 'Tom',
  4. 'gender' => 1,
  5. 'created_at__gte' => 1483228800,
  6. 'order_by' => '-created_at'
  7. );
  8. $query_string = http_build_query($query_data);
  9. $url = "https://cloud.minapp.com/oserve/v1/miniapp/user-profile/?".$query_string;
  10. $ch = curl_init();
  11. $header = array(
  12. "Authorization: Bearer {$token}",
  13. 'Content-Type: application/json; charset=utf-8'
  14. );
  15. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  16. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  17. curl_setopt($ch, CURLOPT_URL, $url);
  18. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  19. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  20. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  21. $res = curl_exec($ch);
  22. curl_close($ch);

{% endtabs %}

返回示例

  1. {
  2. "meta": {
  3. "limit": 20,
  4. "next": null,
  5. "offset": 0,
  6. "previous": null,
  7. "total_count": 1
  8. },
  9. "objects": [{
  10. "avatar": "https://media.ifanrusercontent.com/media/tavatar/55/c3/55c3dbebcc61891be10d29ded808c84a01dxxxxx.jpg",
  11. "city": "Guangzhou",
  12. "country": "China",
  13. "created_at": 1504504504,
  14. "gender": 1,
  15. "id": 550xx,
  16. "nickname": "PCG",
  17. "openid": "onzns0KsLKFyg3-VcW0GwTE6xxxx",
  18. "unionid": "onzns0KsLKFyg3-VcW0GwTE6xxxx",
  19. "province": "Guangdong",
  20. "user_group": [
  21. 137
  22. ],
  23. "user_id": 366197xx
  24. }]
  25. }

用户信息处理

支持自定义字段的查询,更新。

批量获取用户信息

接口

GET https://cloud.minapp.com/oserve/v1/user/info/(后续将废弃该接口,推荐使用以下接口)

GET https://cloud.minapp.com/oserve/v2.2/miniapp/user_profile/

info 该接口支持通过参数 return_total_count 指定是否返回查询对象总数,以协助不关心对象总数只关心查询结果列表的开发者提升接口响应速度。 同时,从 v2.2 版本开始该接口默认不返回查询对象总数,欲获取总数的开发者需要显式指定 return_total_count 参数。

参数说明

参数 类型 必填 说明
where String N 查询语句,参数值应经过 JSON 编码为 JSONString 后,再经过 URL 编码
order_by String N 以下字段不支持排序:gender, country, province, city, language
limit Number N 限制返回资源的个数,默认为 20 条,最大可设置为 1000
offset Number N 设置返回资源的起始偏移值,默认为 0
return_total_count Number N 返回结果 meta 中是否返回 total_count,1 为返回,0 为不返回,默认不返回

若开发者只需要获取对象总数,则可以通过设置 limit=1 以及 return_total_count=1 来达到该效果,total_count 可从返回的 meta 中获取

请求示例:

  1. https://cloud.minapp.com/oserve/v2.2/miniapp/user_profile/?limit=1&return_total_count=1

info where 字段的详细说明请查看:数据模块:数据操作

代码示例

{% tabs bulkGetSingleUserInfoCurl=”Curl”, bulkGetSingleUserInfoNode=”Node”, bulkGetSingleUserInfoPHP=”PHP” %}

{% content “bulkGetSingleUserInfoCurl”%}

  1. curl -X GET \
  2. -H "Authorization: Bearer 35919068aa799eccdef160e1da4bf21381" \
  3. --data-urlencode '{"test": {"$eq":"test"}}'\
  4. https://cloud.minapp.com/oserve/v2.2/miniapp/user_profile/

{% content “bulkGetSingleUserInfoNode” %}

  1. var request = require("request");
  2. var options = {
  3. method: 'GET',
  4. url: 'https://cloud.minapp.com/oserve/v2.2/miniapp/user_profile/',
  5. headers:
  6. {
  7. 'Content-Type': 'application/json',
  8. Authorization: 'Bearer 35919068aa799eccf19160e1da4bf2138'
  9. },
  10. qs: {
  11. where: JSON.stringify({"test": {"$eq": "test"}}),
  12. return_total_count: 1
  13. }
  14. };
  15. var req = request(options, function (error, response, body) {
  16. if (error) throw new Error(error);
  17. console.log(body);
  18. });

{% content “bulkGetSingleUserInfoPHP”%}

  1. <?php
  2. $token = '35919068aa799eccdef19160e1da4bf21381';
  3. $url = "https://cloud.minapp.com/oserve/v2.2/miniapp/user_profile/?";
  4. $ch = curl_init();
  5. $header = array(
  6. "Authorization: Bearer {$token}",
  7. 'Content-Type: application/json; charset=utf-8'
  8. );
  9. $condition = array(
  10. 'where' => json_encode(['test' => ['$eq' => 'test']]),
  11. 'return_total_count' => '1'
  12. );
  13. $url .= http_build_query($condition);
  14. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  15. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  16. curl_setopt($ch, CURLOPT_URL, $url);
  17. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  18. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  19. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  20. $response = curl_exec($ch);
  21. $err = curl_error($ch);
  22. curl_close($ch);
  23. if ($err) {
  24. echo "CURL Error #:" . $err;
  25. } else {
  26. echo $response;
  27. }

{% endtabs %}

返回示例

  1. {
  2. "meta": {
  3. "limit": 20,
  4. "next": null,
  5. "offset": 0,
  6. "previous": null,
  7. "total_count": 2
  8. },
  9. "objects": [
  10. {
  11. "avatar": "https://media.ifanrusercontent.com/tavatar/73/b2/73b23fbd584699bb31a0317c9d4425dcba9xxxx.jpg",
  12. "city": "广州",
  13. "country": "中国",
  14. "created_at": 1542364387,
  15. "created_by": 64501217,
  16. "gender": 1,
  17. "id": 64501217,
  18. "is_authorized": true,
  19. "language": "zh_CN",
  20. "nickname": "你今天真好看",
  21. "openid": "o0b495YcphSE24RbTl7K9dMx_QAA",
  22. "province": "广东",
  23. "test": "test",
  24. "unionid": null,
  25. "updated_at": 1542872767
  26. },
  27. {
  28. "avatar": "https://media.ifanrusercontent.com/tavatar/4d/7c/4d7c5418b262bfa2250fd3b70789ba9d0c6e4603.jpg",
  29. "city": "广州",
  30. "country": "中国",
  31. "created_at": 1542858732,
  32. "created_by": 70695404,
  33. "gender": 0,
  34. "id": 70695404,
  35. "is_authorized": true,
  36. "language": "zh_CN",
  37. "nickname": "你也是",
  38. "openid": "o0b495agcnGojMQbCnlB9AV6OeDw",
  39. "province": "广东",
  40. "test": "test",
  41. "unionid": null,
  42. "updated_at": 1542958030
  43. }
  44. ]
  45. }

状态码说明

200: 成功。

400: where 中的操作符或值错误,排序字段不支持。

401: 未授权,请检查请求头中的 Authorization 字段是否正确。

获取单个用户信息

接口

GET https://cloud.minapp.com/oserve/v1/user/info/:id/(后续将废弃该接口,推荐使用以下接口)

GET https://cloud.minapp.com/oserve/v2.2/miniapp/user_profile/:id/

其中 :id 是用户在 _userprofile 表中的 id

代码示例

{% tabs getSingleUserInfoCurl=”Curl”, getSingleUserInfoNode=”Node”, getSingleUserInfoPHP=”PHP” %}

{% content “getSingleUserInfoCurl”%}

  1. curl -X GET \
  2. -H "Authorization: Bearer 35919068aa799eccdef19160e1da4bf21381d2a2" \
  3. https://cloud.minapp.com/oserve/v2.2/miniapp/user_profile/70695404/

{% content “getSingleUserInfoNode” %}

  1. var request = require("request");
  2. var options = {
  3. method: 'GET',
  4. url: 'https://cloud.minapp.com/oserve/v2.2/miniapp/user_profile/70695404/',
  5. headers:
  6. {
  7. 'Content-Type': 'application/json',
  8. Authorization: 'Bearer 35919068aa799eccdef19160e1da4bf21381d2a2'
  9. },
  10. };
  11. var req = request(options, function (error, response, body) {
  12. if (error) throw new Error(error);
  13. console.log(body);
  14. });

{% content “getSingleUserInfoPHP”%}

  1. <?php
  2. $token = '35919068aa799eccdef19160e1da4bf21381d2a2';
  3. $url = "https://cloud.minapp.com/oserve/v2.2/miniapp/user_profile/70695404/";
  4. $ch = curl_init();
  5. $header = array(
  6. "Authorization: Bearer {$token}",
  7. 'Content-Type: application/json; charset=utf-8'
  8. );
  9. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  10. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  11. curl_setopt($ch, CURLOPT_URL, $url);
  12. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  15. $response = curl_exec($ch);
  16. $err = curl_error($ch);
  17. curl_close($ch);
  18. if ($err) {
  19. echo "CURL Error #:" . $err;
  20. } else {
  21. echo $response;
  22. }

{% endtabs %}

返回示例

  1. {
  2. "avatar": "https://media.ifanrusercontent.com/tavatar/73/b2/73b23fbd584699bb31a0317c9d4425dcba9a.jpg",
  3. "city": "广州",
  4. "country": "中国",
  5. "created_at": 1542364387,
  6. "created_by": 88888,
  7. "gender": 1,
  8. "id": 88888,
  9. "is_authorized": true,
  10. "language": "zh_CN",
  11. "nickname": "你今天真好看",
  12. "openid": "o0b495YcphSE24RbTl7K9dMx_A",
  13. "province": "广东",
  14. "test": "test",
  15. "unionid": null,
  16. "updated_at": 1542872767
  17. }

状态码说明

200: 成功。

401: 未授权,请检查请求头中的 Authorization 字段是否正确。

404: 用户不存在。

更新单个用户信息

接口

PUT https://cloud.minapp.com/oserve/v1/user/info/:id/(后续将废弃该接口,推荐使用以下接口)

PUT https://cloud.minapp.com/oserve/v2.6/miniapp/user_profile/:id/

其中 :id 是用户在 _userprofile 表中的 id

info

  • v2.6 版本前,数据更新操作会结合用户输入数据以及原有的数据行其余字段数据,使用整个数据对象进行保存;
  • v2.6 版本后(包含 v2.6),数据更新操作仅会针对用户输入数据对字段进行单独更新。

代码示例

{% tabs updateSingleUserInfoCurl=”Curl”, updateSingleUserInfoNode=”Node”, updateSingleUserInfoPHP=”PHP” %}

{% content “updateSingleUserInfoCurl”%}

  1. curl -X PUT \
  2. https://cloud.minapp.com/oserve/v2.6/miniapp/user_profile/70695404/ \
  3. -H 'Authorization: Bearer 35919068aa799eccdef19160e1da4bf21381d2a2' \
  4. -H 'Content-Type: application/json' \
  5. -d '{"test": "test"}'

{% content “updateSingleUserInfoNode” %}

  1. var request = require("request");
  2. var options = {
  3. method: 'PUT',
  4. url: 'https://cloud.minapp.com/oserve/v2.6/miniapp/user_profile/70695404/',
  5. headers:
  6. {
  7. 'Content-Type': 'application/json',
  8. Authorization: 'Bearer 35919068aa799eccdef19160e1da4bf21381d2a2'
  9. },
  10. body: { "test": "test" },
  11. json: true
  12. };
  13. var req = request(options, function (error, response, body) {
  14. if (error) throw new Error(error);
  15. console.log(body);
  16. });

{% content “updateSingleUserInfoPHP”%}

  1. <?php
  2. $token = '35919068aa799eccdef19160e1da4bf21381d2a2';
  3. $url = "https://cloud.minapp.com/oserve/v2.6/miniapp/user_profile/70695404/";
  4. $ch = curl_init();
  5. $header = array(
  6. "Authorization: Bearer {$token}",
  7. 'Content-Type: application/json; charset=utf-8'
  8. );
  9. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  10. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  11. curl_setopt($ch, CURLOPT_URL, $url);
  12. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  15. curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"test\": \"test\"}");
  16. $response = curl_exec($ch);
  17. $err = curl_error($ch);
  18. curl_close($ch);
  19. if ($err) {
  20. echo "CURL Error #:" . $err;
  21. } else {
  22. echo $response;
  23. }

{% endtabs %}

返回示例

  1. {
  2. "avatar": "https://media.ifanrusercontent.com/tavatar/4d/7c/4d7c5418b262bfa2250fd3b70789ba9d0c6e4603.jpg",
  3. "city": "广州",
  4. "country": "中国",
  5. "created_at": 1542858732,
  6. "created_by": 70695404,
  7. "gender": 1,
  8. "id": 70695404,
  9. "is_authorized": true,
  10. "language": "zh_CN",
  11. "nickname": "Guoch",
  12. "openid": "o0b495agcnGojMQbCnlB9AV6OeDw",
  13. "province": "广东",
  14. "test": "changed_from_open_api",
  15. "unionid": null,
  16. "updated_at": 1542957870
  17. }

状态码说明

200: 成功。

400: 字段类型不匹配,更新非自定义字段或不存在的字段。

401: 未授权,请检查请求头中的 Authorization 字段是否正确。

404: 用户不存在。

批量修改自定义字段

PUT https://cloud.minapp.com/oserve/v2.6/miniapp/user_profile/

info 该接口支持通过参数 return_total_count 指定是否返回待更新对象总数,以协助不关心对象总数只关心数据更新结果的开发者提升接口响应速度。 同时,从 v2.2 版本开始该接口默认不返回待更新对象总数,欲获取总数的开发者需要显式指定 return_total_count 参数。

Query 参数说明

参数 类型 必填 说明
where String N 查询语句,参数值应经过 JSON 编码为 JSONString 后,再经过 URL 编码
limit Number N 限制单次请求更新的用户数,默认为 20 条,最大可设置为 1000
offset Number N 设置更新的偏移值,默认为 0
return_total_count Number N 返回结果中是否包含 total_count,1 为包含,0 为不包含,默认不包含

info where 字段的详细说明请查看:数据模块:数据操作

参数说明

info 参数与更新数据表数据的参数一致,详细说明请查看:数据模块:更新数据。 支持数据原子性更新,详细说明请查看:数据模块:数据原子性更新

代码示例

{% tabs bulkUpdateUserInfoCurl=”Curl”, bulkUpdateUserInfoNode=”Node”, bulkUpdateUserInfoPHP=”PHP” %}

{% content “bulkUpdateUserInfoCurl”%}

  1. curl -X PUT \
  2. https://cloud.minapp.com/oserve/v2.6/miniapp/user_profile/ \
  3. -H 'Authorization: Bearer 35919068aa799eccdef19160e1da4bf21381d2a2' \
  4. -H 'Content-Type: application/json' \
  5. -d '{"test": "test"}'

{% content “bulkUpdateUserInfoNode” %}

  1. var request = require("request");
  2. var options = {
  3. method: 'PUT',
  4. url: 'https://cloud.minapp.com/oserve/v2.6/miniapp/user_profile/',
  5. headers:
  6. {
  7. 'Content-Type': 'application/json',
  8. Authorization: 'Bearer 35919068aa799eccdef19160e1da4bf21381d2a2'
  9. },
  10. body: { "test": "test" },
  11. json: true
  12. };
  13. var req = request(options, function (error, response, body) {
  14. if (error) throw new Error(error);
  15. console.log(body);
  16. });

{% content “bulkUpdateUserInfoPHP”%}

  1. <?php
  2. $token = '35919068aa799eccdef19160e1da4bf21381d2a2';
  3. $url = "https://cloud.minapp.com/oserve/v2.6/miniapp/user_profile/";
  4. $ch = curl_init();
  5. $header = array(
  6. "Authorization: Bearer {$token}",
  7. 'Content-Type: application/json; charset=utf-8'
  8. );
  9. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  10. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  11. curl_setopt($ch, CURLOPT_URL, $url);
  12. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  15. curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"test\": \"test\"}");
  16. $response = curl_exec($ch);
  17. $err = curl_error($ch);
  18. curl_close($ch);
  19. if ($err) {
  20. echo "CURL Error #:" . $err;
  21. } else {
  22. echo $response;
  23. }

{% endtabs %}

返回示例

  1. {
  2. "operation_result": [
  3. {
  4. "success": {
  5. "id": "5a3c51cdceb616ccfc9d5f78",
  6. "updated_at": 1564411939
  7. }
  8. }
  9. ],
  10. "succeed": 1,
  11. "total_count": 1,
  12. "offset": 0,
  13. "limit": 1000,
  14. "next": null
  15. }

info 返回参数的详细说明请查看:数据模块:同步批量修改数据

状态码说明

200: 成功。

400: 字段类型不匹配,更新非自定义字段或不存在的字段。

401: 未授权,请检查请求头中的 Authorization 字段是否正确。

修改用户登录信息

接口

PUT https://cloud.minapp.com/oserve/v2.1/miniapp/user/account/:id/

其中 :id 是用户在 _userprofile 表中的 id

参数说明

Content-Type: application/json

参数 类型 必填 说明
username string N 用户名,不区分大小写
email string N 邮箱,不区分大小写
new_password string N 设置用户密码
phone string N 新的手机号

如果需要为用户强行修改密码, 传入 new_password 即可。 当设置新的手机号时,phone_verified 重置为 false,需要重新通过验证码进行验证。

如想重置用户的 email/username/phone,可以将 email/username/phone 的值设置为 null。

代码示例

{% tabs updateSingleUserAccountInfoCurl=”Curl”, updateSingleUserAccountInfoNode=”Node”, updateSingleUserAccountInfoPHP=”PHP” %}

{% content “updateSingleUserAccountInfoCurl”%}

  1. curl -X PUT \
  2. https://cloud.minapp.com/oserve/v2.1/miniapp/user/account/70695404/ \
  3. -H 'Authorization: Bearer 35919068aa799eccdef19160e1da4bf21381d2a2' \
  4. -H 'Content-Type: application/json' \
  5. -d '{"username": "pretty_girl"}'

{% content “updateSingleUserAccountInfoNode” %}

  1. var request = require("request");
  2. var options = {
  3. method: 'PUT',
  4. url: 'https://cloud.minapp.com/oserve/v2.1/miniapp/user/account/70695404/',
  5. headers:
  6. {
  7. 'Content-Type': 'application/json',
  8. Authorization: 'Bearer 35919068aa799eccdef19160e1da4bf21381d2a2'
  9. },
  10. body: { 'username': 'pretty_girl' },
  11. json: true
  12. };
  13. var req = request(options, function (error, response, body) {
  14. if (error) throw new Error(error);
  15. console.log(body);
  16. });

{% content “updateSingleUserAccountInfoPHP”%}

  1. <?php
  2. $token = '35919068aa799eccdef19160e1da4bf21381d2a2';
  3. $url = "https://cloud.minapp.com/oserve/v2.1/miniapp/user/account/70695404/";
  4. $ch = curl_init();
  5. $header = [
  6. "Authorization: Bearer {$token}",
  7. "Content-Type: application/json; charset=utf-8"
  8. ];
  9. $payload = json_encode([
  10. "username" => "pretty_girl_php"]);
  11. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  12. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  13. curl_setopt($ch, CURLOPT_URL, $url);
  14. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
  15. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  16. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  17. curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
  18. $response = curl_exec($ch);
  19. $err = curl_error($ch);
  20. curl_close($ch);
  21. if ($err) {
  22. echo "CURL Error #:" . $err;
  23. } else {
  24. echo $response;
  25. }

{% endtabs %}

返回示例

  1. {
  2. "email": "pretty_girl@example.com",
  3. "email_verified": false,
  4. "username": "pretty_girl",
  5. "phone": "13800138000",
  6. "phone_verified": true
  7. }

返回参数说明

参数 类型 说明
email string 目前的邮箱
email_verified boolean 邮箱是否已经验证
username string 目前的用户名
phone string 手机号码
phone_verified boolean 手机号码是否已经验证

状态码说明

200: 成功。

400: password 错误、email 不合法、username 或 email 已经存在。

401: 未授权,请检查请求头中的 Authorization 字段是否正确。

404: 用户不存在。