# 接口调用

# 获取第三方应用凭证

suite_access_token 是第三方应用调用接口时的唯一凭证,开发者必须妥善保存。

suite_access_token 目前有效时间为2小时,开发者需要缓存,避免频繁调用获取 suite_access_token 接口导致超出频率限制被拦截。

# 接口调用说明:

POST https://lxapi.lexiangla.com/cgi-bin/service/get_suite_token

# 请求数据编码格式:

Content-Type: application/json

# 请求参数

{
    "grant_type": "GRANT_TYPE",
    "suite_id": "SUITE_ID",
    "suite_secret": "SUITE_SECRET",
    "suite_ticket": "SUITE_TICKET"
}

# 参数说明:

参数 是否必须 说明
grant_type 使用固定值 client_credentials
suite_id 应用唯一标识
suite_secret 密钥
suite_ticket 乐享定期推送的 suite_ticket

# 接口正常返回说明:

# 200 OK 状态码
{
  "token_type": "Bearer",
  "expires_in": 7200,
  "suite_access_token": "XXXXXXXXX"
}
参数 说明
token_type Token 类型
expires_in 凭证有效时间,单位:秒
suite_access_token 凭证

# 接口错误返回说明:

# 400 Bad Request 状态码

参数错误,如 app_key 不存在,缺少必填参数,grant_type 错误等

# 429 Too Many Requests 状态码

请求超出频率限制

# 获取企业永久授权码

# 接口调用说明:

POST https://lxapi.lexiangla.com/cgi-bin/service/get_permanent_code?suite_access_token=SUITE_ACCESS_TOKEN

# 请求数据编码格式:

Content-Type: application/json

# 请求参数

{
    "auth_code": "AUTH_CODE"
}

# 参数说明:

参数 是否必须 说明
suite_access_token 第三方应用接口调用凭证
auth_code 临时授权码

# 接口正常返回说明:

# 200 OK 状态码
{
	"data": {
		"company_id": "COMPANY_ID",
		"permanent_code": "PERMANENT_CODE",
        "auth_corp_info": {
            "company_id": "COMPANY_ID",
            "name": "腾讯乐享",
            "square_logo": "https://xxx.com/1.png",
            "logo": "https://xxx.com/2.png",
            "staff_count": 3200
        },
        "auth_user_info": {
            "staff_id": "ThreeZhang",
            "name": "张三"
        }
	},
	"msg": "success",
	"code": 0
}
参数 说明
company_id 企业唯一标识
permanent_code 企业永久授权码
auth_corp_info.company_id 同company_id
auth_corp_info.name 企业名称
auth_corp_info.square_logo 企业正方形Logo(需要服务商自行持久化存储)
auth_corp_info.logo 企业长方形Logo(需要服务商自行持久化存储)
auth_corp_info.staff_count 授权成员数量
auth_user_info.staff_id 授权人的员工ID
auth_user_info.name 授权人的姓名

# 获取企业凭证

access_token 是第三方调用应用接口时的唯一凭证,开发者必须妥善保存。

access_token 目前有效时间为2小时,开发者需要缓存,避免频繁调用获取 access_token 接口导致超出频率限制被拦截。

# 接口调用说明:

POST https://lxapi.lexiangla.com/cgi-bin/service/get_corp_token?suite_access_token=SUITE_ACCESS_TOKEN

# 请求数据编码格式:

Content-Type: application/json

# 请求参数

{
    "grant_type": "GRANT_TYPE",
    "company_id": "COMPANY_ID",
    "permanent_code": "PERMANENT_CODE"
}

# 参数说明:

参数 是否必须 说明
suite_access_token 第三方应用接口调用凭证
grant_type 使用固定值 client_credentials
company_id 企业唯一标识
permanent_code 企业永久授权码

# 接口正常返回说明:

# 200 OK 状态码
{
  "token_type": "Bearer",
  "expires_in": 7200,
  "access_token": "XXXXXXXXX"
}
参数 说明
token_type Token 类型
expires_in 凭证有效时间,单位:秒
access_token 凭证

# 接口错误返回说明:

# 400 Bad Request 状态码

参数错误,如 app_key 不存在,缺少必填参数,grant_type 错误等

# 429 Too Many Requests 状态码

请求超出频率限制

# 使用企业凭证:

调用任何一个企业接口(通讯录接口、应用接口、内容上传接口等)时,请求都必须带上 access_token。

设置方式有2种,假设获取到的 access_token 为 xxxxxxxxxxx

方式1:HTTP Header 设置格式如下:

Authorization: Bearer xxxxxxxxxxx

方式2:url上直接带上 ?access_token=xxxxxxxxxxx

在请求应用接口时必须用有效的 access_token,否则会返回 401 Unauthorized 错误。

# 获取应用的管理员列表

# 接口调用说明:

GET https://lxapi.lexiangla.com/cgi-bin/service/get_admin_list?suite_access_token=SUITE_ACCESS_TOKEN&company_id=COMPANY_ID

# 参数说明:

参数 是否必须 说明
COMPANY_ID 企业唯一标识

# 接口正常返回说明:

# 200 OK 状态码
{
    "data": [
        {
            "staff_id": "ThreeZhang",
            "name": "张三"
        },
        {
            "staff_id": "FourLee",
            "name": "李四"
        }
    ],
    "msg": "success",
    "code": 0
}
参数 说明
staff_id 管理员的员工ID
name 管理员的姓名