Skip to content

生成授权token

生成授权token信息

请求参数类型描述
jsonobject声明请求的JSON数据结构
openidstring用户标识
appidstring应用ID
sub_appidstring子商户应用ID
sub_mchidstring子商户号
user_namestring用户实名
id_card_numberstring用户证件号
employment_typestring用工类型
LONG_TERM_EMPLOYMENT | SHORT_TERM_EMPLOYMENT | COOPERATION_EMPLOYMENT 枚举值之一
headersobject声明请求的头参数
Wechatpay-Serialstring平台公钥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));
返回字典类型描述
openidstring用户标识
mchidstring服务商商户号
sub_mchidstring子商户号
tokenstring授权token
expires_inintegertoken有效时间

参阅 官方文档

Published on the GitHub by TheNorthMemory