identification.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. require dirname(__FILE__) . '/../init.php';
  3. // api_key 获取方式:登录 [Dashboard](https://dashboard.pingxx.com)->点击管理平台右上角公司名称->开发信息-> Secret Key
  4. $api_key = 'sk_test_ibbTe5jLGCi5rzfH4OqPW9KC';
  5. // app_id 获取方式:登录 [Dashboard](https://dashboard.pingxx.com)->点击你创建的应用->应用首页->应用 ID(App ID)
  6. $app_id = 'app_1Gqj58ynP0mHeX1q';
  7. // 设置 API Key
  8. \Pingpp\Pingpp::setApiKey($api_key);
  9. // 设置私钥
  10. \Pingpp\Pingpp::setPrivateKeyPath(__DIR__ . '/your_rsa_private_key.pem');
  11. // 调用身份证认证接口
  12. try {
  13. $result = \Pingpp\Identification::identify(array(
  14. 'type' => 'id_card',
  15. 'app' => $app_id,
  16. 'data' => array(
  17. 'id_name' => '张三', // 姓名
  18. 'id_number' => '310181198910107641' // 身份证号
  19. )
  20. ));
  21. echo $result;
  22. } catch (\Pingpp\Error\Base $e) {
  23. echo $e->getMessage();
  24. }
  25. // 调用银行卡认证接口
  26. try {
  27. $result = \Pingpp\Identification::identify(array(
  28. 'type' => 'bank_card',
  29. 'app' => $app_id,
  30. 'data' => array(
  31. 'id_name' => '张三', // 姓名
  32. 'id_number' => '310181198910107641', // 身份证号,
  33. 'card_number' => '6201111122223333', // 银行卡号
  34. 'phone_number' => '18623234545' // 银行预留手机号,不支持 178 号段
  35. )
  36. ));
  37. echo $result;
  38. } catch (\Pingpp\Error\Base $e) {
  39. echo $e->getMessage();
  40. }