生成企业认证令牌
请求地址
/companyauth/miniappexchange
请求方式
POST
请求格式
application/json;charset=UTF-8
请求参数
参数名称 | 类型 | 必须 | 描述 |
---|---|---|---|
companyName | String | 是 | 待认证公司名称 |
applicant | User | 是 | 认证提交人,企业认证通过后,认证提交人会自动成为该企业的系统管理员 |
registerNo | String | 否 | 待认证公司注册号 |
legalPerson | String | 否 | 待认证公司法人姓名 |
callbackUrl | String | 否 | 认证回调地址 |
closeButton | Boolean | 否 | 是否显示关闭按钮,默认为true |
modifyFields | String | 否 | 可修改项参数,支持传入字段:corpName(待认证公司名称)、registerNo(待认证公司注册号)、legalPerson(待认证公司法人姓名),传入的字段,用户在企业认证页面可支持修改,多个字段用逗号隔开(例:corpName,registerNo) |
User(提交人信息,企业认证通过后,提交人对应的账号会自动成为该公司的管理员) :
名称 | 类型 | 必须 | 描述 |
---|---|---|---|
name | String | 否 | 申请者姓名 |
contact | String | 是 | 联系方式 |
contactType | String | 是 | 联系方式类型:MOBILE、EMAIL |
返回参数
名称 | 类型 | 描述 |
---|---|---|
code | Integer | 响应码 |
message | String | 响应消息 |
result | Result | 认证令牌信息 |
Result(认证令牌):
名称 | 类型 | 描述 |
---|---|---|
ticket | String | 令牌内容 |
响应码
(全局响应码请查看文档末“全局响应码”):
响应码 | 描述 |
---|---|
1605 | COMPANY ALREADY AUTHED,该公司已完成认证 |
请求示例
Http示例
POST /companyauth/miniappexchange HTTP/1.1
Host: [host]
x-qys-open-timestamp: [替换为请求头生成的Timestamp]
x-qys-open-signature: [替换为请求头生成的Signature]
x-qys-open-accesstoken: [替换为请求头生成的Token]
Content-Type: application/json
{
"companyName":"上海契约锁公司",
"applicant":{
"name":"张三",
"contact":"12312378900",
"contactType":"MOBILE"
},
"callbackUrl":"http://www.qiyuesuo.com"
}
Java示例
// 初始化sdkClient
String serverUrl = "https://openapi.qiyuesuo.cn";
String accessKey = "替换为您申请的开放平台App Token";
String accessSecret = "替换为您申请的开放平台App Secret";
SdkClient sdkClient = new SdkClient(serverUrl, accessKey, accessSecret);
User applicant = new User("张三", "12312378900", "MOBILE");
CompanyAuthMiniappTicketRequest request = new CompanyAuthMiniappTicketRequest("上海契约锁公司", new User("12312378900", "MOBILE"));
String response = null;
try {
response = sdkClient.service(request);
} catch (Exception e) {
throw new BaseSdkException("调用接口错误,错误原因:" + e.getMessage());
}
SdkResponse<MiniappTicketResult> result = JSONUtils.toQysResponse(response, MiniappTicketResult.class);
if (!result.getCode().equals(0)) {
throw new BaseSdkException("获取企业认证Ticket失败,失败原因:" + result.getCode() + "," + result.getMessage());
}
logger.info("获取企业认证Ticket成功,Ticket:" + result.getResult().getTicket());
C#示例
// 初始化sdkClient
string serverUrl = "https://openapi.qiyuesuo.cn";
string accessKey = "替换为您申请的开放平台App Token";
string accessSecret = "替换为您申请的开放平台App Secret";
SDKClient client = new SDKClient(accessKey, accessSecret, serverUrl);
CompanyAuthMiniappTicketRequest request = new CompanyAuthMiniappTicketRequest("上海契约锁公司",new User("12312378900", "MOBILE"));
string response = null;
try
{
response = client.Service(request);
}
catch (Exception e)
{
throw new Exception("访问接口失败,失败原因:" + e.Message);
}
SdkResponse<MiniappTicketResult> responseObject = HttpJsonConvert.DeserializeResponse<MiniappTicketResult>(response);
if (!responseObject.Code.Equals(0))
{
Console.WriteLine("获取企业认证Ticket失败,失败原因:" + responseObject.Code + "," + responseObject.Message);
}
else
{
Console.WriteLine("获取企业认证Ticket成功,ticket:" + responseObject.Result.Ticket);
}
PHP示例
// 初始化$sdkClient
class Util {
const url = "https://openapi.qiyuesuo.cn";
const accessKey = "替换为您申请的开放平台App Token";
const accessSecret = "替换为您申请的开放平台App Secret";
}
$sdkClient = Util::getSDk();
$companyName = '企业认证链接';
// 认证提交人信息
$user = new User();
$user->setName('胡*坤');
$user->setContact('151****6497');
$user->setContactType('MOBILE');
$applicant = $user;
$baseRequest = new CompanyAuthMiniappTicketRequest($companyName, $applicant);
$baseRequest->setRegisterNo('1001001001');
$baseRequest->setLegalPerson('胡*坤');
$baseRequest->setCallbackUrl('http://www.baidu.com');
$result = $sdkClient->service($baseRequest);
print_r($result);
Python示例
# 初始化SdkClient
url = "https://openapi.qiyuesuo.cn"
accessToken = '替换为您申请的开放平台App Token'
accessSecret = '替换为您申请的开放平台App Secret'
sdkClient = SdkClient(url, accessToken, accessSecret)
request = CompanyAuthMiniappTicketRequest()
request.set_companyName("HZK测试企业-111")
applicant = User("HZK", "151****6497", "MOBILE")
request.set_applicant(applicant)
auth_h5_page_response = sdkClient.request(request)
print(auth_h5_page_response)