三方账号服务API

更新时间:2019-08-28 14:53:56

本文档是三方账号服务API说明。当您需要导入自有账号体系时,需要使用这些API服务。

账号导入(单个)

/user/account/thirdparty/import

请求示例

// https://github.com/aliyun/iotx-api-gateway-client
IoTApiClientBuilderParams ioTApiClientBuilderParams = new IoTApiClientBuilderParams();

ioTApiClientBuilderParams.setAppKey("你的<AppKey>");
ioTApiClientBuilderParams.setAppSecret("你的<AppSecret>");

SyncApiClient syncApiClient = new SyncApiClient(ioTApiClientBuilderParams);

IoTApiRequest request = new IoTApiRequest();

// 设置请求ID
String uuid = UUID.randomUUID().toString();
String id = uuid.replace("-", "");
request.setId(id);
// 设置API版本号
request.setApiVer("1.0.0");
// 设置参数
request.putParam("openId","value1");
request.putParam("nickName","value2");
request.putParam("phone","value3");
request.putParam("email","value4");
request.putParam("avatarUrl","value5");
request.putParam("creater","value6");
request.putParam("loginName","value7");
// 如果需要,设置headers
Map<String, String> headers = new HashMap<String, String>(8);
// headers.put("你的<header", "你的<value>");

// 设置请求参数域名、path、request , isHttps, headers
ApiResponse response = syncApiClient.postBody("api.link.aliyun.com", "/user/account/thirdparty/import", request, true, headers);

System.out.println(
    "response code = " + response.getCode()
        + " response = " + new String(response.getBody(), "UTF-8")
        + " headers = " + response.getHeaders().toString()
);

响应示例

{
    "id": "4de2c367-c1db-417c-aa15-8c585e595d92",
    "code": 200,
    "message": null,
    "localizedMsg": null,
    "data": "279652150bd04661a4b7006982f4d2c1"
}

失败响应示例

{
    "id": "37f7e5fa-d6a5-4efe-8abf-5bf23dca6284",
    "code": 403,
    "message": "request forbidden.",
    "localizedMsg": "请求被禁止",
    "data": null
}

账号导入(批量)

/user/account/thirdparty/batchimport

调用示例

// https://github.com/aliyun/iotx-api-gateway-client
IoTApiClientBuilderParams ioTApiClientBuilderParams = new IoTApiClientBuilderParams();

ioTApiClientBuilderParams.setAppKey("你的<AppKey>");
ioTApiClientBuilderParams.setAppSecret("你的<AppSecret>");

SyncApiClient syncApiClient = new SyncApiClient(ioTApiClientBuilderParams);

IoTApiRequest request = new IoTApiRequest();

// 设置请求ID
String uuid = UUID.randomUUID().toString();
String id = uuid.replace("-", "");
request.setId(id);
// 设置API版本号
request.setApiVer("1.0.0");
// 设置参数
request.putParam("thirdAccountMetaList","value1");
// 如果需要,设置headers
Map<String, String> headers = new HashMap<String, String>(8);
// headers.put("你的<header", "你的<value>");

// 设置请求参数域名、path、request , isHttps, headers
ApiResponse response = syncApiClient.postBody("api.link.aliyun.com", "/user/account/thirdparty/batchimport", request, true, headers);

System.out.println(
    "response code = " + response.getCode()
        + " response = " + new String(response.getBody(), "UTF-8")
        + " headers = " + response.getHeaders().toString()
);

响应示例

{
    "id": "4de2c367-c1db-417c-aa15-8c585e595d92",
    "code": 200,
    "message": null,
    "localizedMsg": null,
    "data": [
        "2222bd04661a4b7006982f4d2c1",
        "33330bd04661a4b7006982f4d2c1"
    ]
}

失败响应示例

{
    "id": "37f7e5fa-d6a5-4efe-8abf-5bf23dca6284",
    "code": 403,
    "message": "request forbidden.",
    "localizedMsg": "请求被禁止",
    "data": null
}

批量获取账号详细信息

/user/account/thirdparty/query

请求示例

// https://github.com/aliyun/iotx-api-gateway-client
IoTApiClientBuilderParams ioTApiClientBuilderParams = new IoTApiClientBuilderParams();

ioTApiClientBuilderParams.setAppKey("你的<AppKey>");
ioTApiClientBuilderParams.setAppSecret("你的<AppSecret>");

SyncApiClient syncApiClient = new SyncApiClient(ioTApiClientBuilderParams);

IoTApiRequest request = new IoTApiRequest();

// 设置请求ID
String uuid = UUID.randomUUID().toString();
String id = uuid.replace("-", "");
request.setId(id);
// 设置API版本号
request.setApiVer("1.0.0");
// 设置参数
request.putParam("pageNo","value1");
request.putParam("pageSize","value2");
// 如果需要,设置headers
Map<String, String> headers = new HashMap<String, String>(8);
// headers.put("你的<header", "你的<value>");

// 设置请求参数域名、path、request , isHttps, headers
ApiResponse response = syncApiClient.postBody("api.link.aliyun.com", "/user/account/thirdparty/query", request, true, headers);

System.out.println(
    "response code = " + response.getCode()
        + " response = " + new String(response.getBody(), "UTF-8")
        + " headers = " + response.getHeaders().toString()
);

响应示例

{
    "id": "4de2c367-c1db-417c-aa15-8c585e595d92",
    "code": 200,
    "message": null,
    "localizedMsg": null,
    "data": {
      "pageNo": 1,
      "total":3,
      "thirdAccountMetaList": [
        {
          "openId": "ln15132207455",
          "nickName": "test1",
          "loginName": "abc",
          "phone": "15132207411",
          "email": "15132207411@mail.com",
          "avatarUrl":"https://www.a.com/ab.jpg",
          "creater":"tester"
        },
        {
          "openId": "ln15132207444",
          "nickName": "test1",
          "loginName": "abc",
          "phone": "15132207412",
          "email": "15132207412@mail.com",
          "avatarUrl":"https://www.a.com/ac.jpg",
          "creater":"tester"
        },
        {
          "openId": "ln15132207433",
          "nickName": "test1",
          "loginName": "abc",
          "phone": "15132207413",
          "email": "15132207413@mail.com",
          "avatarUrl":"https://www.a.com/ad.jpg",
          "creater":"tester"
        }
      ]
    }
}

失败响应示例

{
    "id": "37f7e5fa-d6a5-4efe-8abf-5bf23dca6284",
    "code": 403,
    "message": "request forbidden.",
    "localizedMsg": "请求被禁止",
    "data": null
}

根据三方提供的openId查询IoT

/user/account/thirdparty/openid/get

请求示例

// https://github.com/aliyun/iotx-api-gateway-client
IoTApiClientBuilderParams ioTApiClientBuilderParams = new IoTApiClientBuilderParams();

ioTApiClientBuilderParams.setAppKey("你的<AppKey>");
ioTApiClientBuilderParams.setAppSecret("你的<AppSecret>");

SyncApiClient syncApiClient = new SyncApiClient(ioTApiClientBuilderParams);

IoTApiRequest request = new IoTApiRequest();

// 设置请求ID
String uuid = UUID.randomUUID().toString();
String id = uuid.replace("-", "");
request.setId(id);
// 设置API版本号
request.setApiVer("1.0.0");
// 设置参数
request.putParam("openId","value1");
// 如果需要,设置headers
Map<String, String> headers = new HashMap<String, String>(8);
// headers.put("你的<header", "你的<value>");

// 设置请求参数域名、path、request , isHttps, headers
ApiResponse response = syncApiClient.postBody("api.link.aliyun.com", "/user/account/thirdparty/openid/get", request, true, headers);

System.out.println(
    "response code = " + response.getCode()
        + " response = " + new String(response.getBody(), "UTF-8")
        + " headers = " + response.getHeaders().toString()
);

响应示例

{
    "id": "4de2c367-c1db-417c-aa15-8c585e595d92",
    "code": 200,
    "message": null,
    "localizedMsg": null,
    "data": {
        "identityId":"5002ope01e511f50fd0355f4e92fce7bc9d32677",
        "openId":"12345",
        "phone":"13899999999",
        "email":"aa@aa.com",
        "loginName":"abc",
        "nickName":"tester",
        "creater":"admin",
        "avatarUrl":"http://www.a.com"
    }
}

失败响应示例

{
    "id": "4dbec237-8511-451b-80d9-4264178f9fff",
    "code": 2407,
    "message": "openId invalid",
    "localizedMsg": "openId invalid",
    "data": null
}

results matching ""

    No results matching ""