生成授权token
生成授权token信息
请求参数 | 类型 | 描述 |
---|---|---|
json | object | 声明请求的JSON 数据结构 |
openid | string | 用户标识 |
appid | string | 应用ID |
sub_appid | string | 子商户应用ID |
sub_mchid | string | 子商户号 |
user_name | string | 用户实名 |
id_card_number | string | 用户证件号 |
employment_type | string | 用工类型LONG_TERM_EMPLOYMENT | SHORT_TERM_EMPLOYMENT | COOPERATION_EMPLOYMENT 枚举值之一 |
headers | object | 声明请求的头参数 |
Wechatpay-Serial | string | 平台公钥ID/平台公钥证书序列号 |
php
$instance->v3->payrollCard->tokens->postAsync([
'json' => [
'openid' => '9x111111',
'appid' => 'wxa1111111',
'sub_appid' => 'wxa1111111',
'sub_mchid' => '1111111',
'user_name' => 'LP7bT4hQXUsOZCEvK2YrSiqFsnP0oRMfeoLN0vBg',
'id_card_number' => '7FzH5XksJG3a8HLLsaaUV6K54y1OnPMY5',
'employment_type' => 'LONG_TERM_EMPLOYMENT',
],
'headers' => [
'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance->chain('v3/payroll-card/tokens')->postAsync([
'json' => [
'openid' => '9x111111',
'appid' => 'wxa1111111',
'sub_appid' => 'wxa1111111',
'sub_mchid' => '1111111',
'user_name' => 'LP7bT4hQXUsOZCEvK2YrSiqFsnP0oRMfeoLN0vBg',
'id_card_number' => '7FzH5XksJG3a8HLLsaaUV6K54y1OnPMY5',
'employment_type' => 'LONG_TERM_EMPLOYMENT',
],
'headers' => [
'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$instance['v3/payroll-card/tokens']->postAsync([
'json' => [
'openid' => '9x111111',
'appid' => 'wxa1111111',
'sub_appid' => 'wxa1111111',
'sub_mchid' => '1111111',
'user_name' => 'LP7bT4hQXUsOZCEvK2YrSiqFsnP0oRMfeoLN0vBg',
'id_card_number' => '7FzH5XksJG3a8HLLsaaUV6K54y1OnPMY5',
'employment_type' => 'LONG_TERM_EMPLOYMENT',
],
'headers' => [
'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
print_r(json_decode((string) $response->getBody(), true));
})
->wait();
php
$response = $instance->v3->payrollCard->tokens->post([
'json' => [
'openid' => '9x111111',
'appid' => 'wxa1111111',
'sub_appid' => 'wxa1111111',
'sub_mchid' => '1111111',
'user_name' => 'LP7bT4hQXUsOZCEvK2YrSiqFsnP0oRMfeoLN0vBg',
'id_card_number' => '7FzH5XksJG3a8HLLsaaUV6K54y1OnPMY5',
'employment_type' => 'LONG_TERM_EMPLOYMENT',
],
'headers' => [
'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance->chain('v3/payroll-card/tokens')->post([
'json' => [
'openid' => '9x111111',
'appid' => 'wxa1111111',
'sub_appid' => 'wxa1111111',
'sub_mchid' => '1111111',
'user_name' => 'LP7bT4hQXUsOZCEvK2YrSiqFsnP0oRMfeoLN0vBg',
'id_card_number' => '7FzH5XksJG3a8HLLsaaUV6K54y1OnPMY5',
'employment_type' => 'LONG_TERM_EMPLOYMENT',
],
'headers' => [
'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
],
]);
print_r(json_decode((string) $response->getBody(), true));
php
$response = $instance['v3/payroll-card/tokens']->post([
'json' => [
'openid' => '9x111111',
'appid' => 'wxa1111111',
'sub_appid' => 'wxa1111111',
'sub_mchid' => '1111111',
'user_name' => 'LP7bT4hQXUsOZCEvK2YrSiqFsnP0oRMfeoLN0vBg',
'id_card_number' => '7FzH5XksJG3a8HLLsaaUV6K54y1OnPMY5',
'employment_type' => 'LONG_TERM_EMPLOYMENT',
],
'headers' => [
'Wechatpay-Serial' => 'PUB_KEY_ID_0114232134912410000000000000',
],
]);
print_r(json_decode((string) $response->getBody(), true));
返回字典 | 类型 | 描述 |
---|---|---|
openid | string | 用户标识 |
mchid | string | 服务商商户号 |
sub_mchid | string | 子商户号 |
token | string | 授权token |
expires_in | integer | token有效时间 |
参阅 官方文档