Skip to content

人脸识别SDK-获取调用凭证

人脸识别通过识别用户人脸,获取用户信息(openid)。此功能常用于商户会员、商品推荐等场景, 此流程无法用于支付。FACEID-ONCE为直接启动人脸识别流程。

请求参数类型描述
base_uristring声明接入点
固定值https://payapp.weixin.qq.com/
xmlobject声明请求的XML数据结构
store_idstring门店编号, 由商户定义, 各门店唯一。
store_namestring门店名称,由商户定义。(可用于展示)
device_idstring终端设备编号,由商户定义。
attachstring附加字段。字段格式使用Json
rawdatastring初始化数据。由微信人脸SDK的接口返回。
appidstring商户号绑定的公众号/小程序 appid
mch_idstring商户号
sub_appidstring子商户绑定的公众号/小程序 appid(服务商模式)
sub_mch_idstring子商户号(服务商模式)
nowinteger取当前时间,10位unix时间戳。
versionstring版本号。固定为1
1 枚举值
sign_typestring签名类型
MD5 | HMAC-SHA256 枚举值之一
php
$instance->v2->face->get_wxpayface_authinfo->postAsync([
  'base_uri' => 'https://payapp.weixin.qq.com/', // 接入点
  'xml' => [
    'store_id'   => 'IMG001',
    'store_name' => '爱马哥南山店',
    'device_id'  => 'DEV001',
    'attach'     => '',
    'rawdata'    => 'H0kvnUgGHKuqflNwtNqCdOVpbO4FPSowudTG',
    'appid'      => 'wx31fdaErqR31',
    'mch_id'     => '12345689',
    'sub_appid'  => 'wx31fdaErqR31',
    'sub_mch_id' => '12345689',
    'now'        => '1239878956',
    'version'    => '1',
    'sign_type'  => 'MD5',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance->chain('v2/face/get_wxpayface_authinfo')->postAsync([
  'base_uri' => 'https://payapp.weixin.qq.com/', // 接入点
  'xml' => [
    'store_id'   => 'IMG001',
    'store_name' => '爱马哥南山店',
    'device_id'  => 'DEV001',
    'attach'     => '',
    'rawdata'    => 'H0kvnUgGHKuqflNwtNqCdOVpbO4FPSowudTG',
    'appid'      => 'wx31fdaErqR31',
    'mch_id'     => '12345689',
    'sub_appid'  => 'wx31fdaErqR31',
    'sub_mch_id' => '12345689',
    'now'        => '1239878956',
    'version'    => '1',
    'sign_type'  => 'MD5',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$instance['v2/face/get_wxpayface_authinfo']->postAsync([
  'base_uri' => 'https://payapp.weixin.qq.com/', // 接入点
  'xml' => [
    'store_id'   => 'IMG001',
    'store_name' => '爱马哥南山店',
    'device_id'  => 'DEV001',
    'attach'     => '',
    'rawdata'    => 'H0kvnUgGHKuqflNwtNqCdOVpbO4FPSowudTG',
    'appid'      => 'wx31fdaErqR31',
    'mch_id'     => '12345689',
    'sub_appid'  => 'wx31fdaErqR31',
    'sub_mch_id' => '12345689',
    'now'        => '1239878956',
    'version'    => '1',
    'sign_type'  => 'MD5',
  ],
])
->then(static function(\Psr\Http\Message\ResponseInterface $response) {
  print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
})
->wait();
php
$response = $instance->v2->face->get_wxpayface_authinfo->post([
  'base_uri' => 'https://payapp.weixin.qq.com/', // 接入点
  'xml' => [
    'store_id'   => 'IMG001',
    'store_name' => '爱马哥南山店',
    'device_id'  => 'DEV001',
    'attach'     => '',
    'rawdata'    => 'H0kvnUgGHKuqflNwtNqCdOVpbO4FPSowudTG',
    'appid'      => 'wx31fdaErqR31',
    'mch_id'     => '12345689',
    'sub_appid'  => 'wx31fdaErqR31',
    'sub_mch_id' => '12345689',
    'now'        => '1239878956',
    'version'    => '1',
    'sign_type'  => 'MD5',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance->chain('v2/face/get_wxpayface_authinfo')->post([
  'base_uri' => 'https://payapp.weixin.qq.com/', // 接入点
  'xml' => [
    'store_id'   => 'IMG001',
    'store_name' => '爱马哥南山店',
    'device_id'  => 'DEV001',
    'attach'     => '',
    'rawdata'    => 'H0kvnUgGHKuqflNwtNqCdOVpbO4FPSowudTG',
    'appid'      => 'wx31fdaErqR31',
    'mch_id'     => '12345689',
    'sub_appid'  => 'wx31fdaErqR31',
    'sub_mch_id' => '12345689',
    'now'        => '1239878956',
    'version'    => '1',
    'sign_type'  => 'MD5',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
php
$response = $instance['v2/face/get_wxpayface_authinfo']->post([
  'base_uri' => 'https://payapp.weixin.qq.com/', // 接入点
  'xml' => [
    'store_id'   => 'IMG001',
    'store_name' => '爱马哥南山店',
    'device_id'  => 'DEV001',
    'attach'     => '',
    'rawdata'    => 'H0kvnUgGHKuqflNwtNqCdOVpbO4FPSowudTG',
    'appid'      => 'wx31fdaErqR31',
    'mch_id'     => '12345689',
    'sub_appid'  => 'wx31fdaErqR31',
    'sub_mch_id' => '12345689',
    'now'        => '1239878956',
    'version'    => '1',
    'sign_type'  => 'MD5',
  ],
]);
print_r(\WeChatPay\Transformer::toArray((string) $response->getBody()));
返回字典类型描述
return_codestring返回状态码
SUCCESS | FAIL 枚举值之一
return_msgstring错误码描述
authinfostringSDK调用凭证。用于调用SDK的人脸识别接口。
expires_inintegerauthinfo的有效时间, 单位秒。
nonce_strstring随机字符串,不长于32位
signstring参数签名。
appidstring公众号
mch_idstring商户号
sub_appidstring子商户公众账号ID(服务商模式)
sub_mch_idstring子商户号(服务商模式)

参阅 官方文档

Published on the GitHub by TheNorthMemory