Ocr.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2022 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | github开源项目:https://github.com/zoujingli/WeChatDeveloper
  12. // +----------------------------------------------------------------------
  13. namespace WeMini;
  14. use WeChat\Contracts\BasicWeChat;
  15. /**
  16. * 小程序ORC服务
  17. * Class Ocr
  18. * @package WeMini
  19. */
  20. class Ocr extends BasicWeChat
  21. {
  22. /**
  23. * 本接口提供基于小程序的银行卡 OCR 识别
  24. * @param array $data
  25. * @return array
  26. * @throws \WeChat\Exceptions\InvalidResponseException
  27. * @throws \WeChat\Exceptions\LocalCacheException
  28. */
  29. public function bankcard($data)
  30. {
  31. $url = 'https://api.weixin.qq.com/cv/ocr/bankcard?access_token=ACCESS_TOCKEN';
  32. return $this->callPostApi($url, $data, true);
  33. }
  34. /**
  35. * 本接口提供基于小程序的营业执照 OCR 识别
  36. * @param array $data
  37. * @return array
  38. * @throws \WeChat\Exceptions\InvalidResponseException
  39. * @throws \WeChat\Exceptions\LocalCacheException
  40. */
  41. public function businessLicense($data)
  42. {
  43. $url = 'https://api.weixin.qq.com/cv/ocr/bizlicense?access_token=ACCESS_TOCKEN';
  44. return $this->callPostApi($url, $data, true);
  45. }
  46. /**
  47. * 本接口提供基于小程序的驾驶证 OCR 识别
  48. * @param array $data
  49. * @return array
  50. * @throws \WeChat\Exceptions\InvalidResponseException
  51. * @throws \WeChat\Exceptions\LocalCacheException
  52. */
  53. public function driverLicense($data)
  54. {
  55. $url = 'https://api.weixin.qq.com/cv/ocr/drivinglicense?access_token=ACCESS_TOCKEN';
  56. return $this->callPostApi($url, $data, true);
  57. }
  58. /**
  59. * 本接口提供基于小程序的身份证 OCR 识别
  60. * @param array $data
  61. * @return array
  62. * @throws \WeChat\Exceptions\InvalidResponseException
  63. * @throws \WeChat\Exceptions\LocalCacheException
  64. */
  65. public function idcard($data)
  66. {
  67. $url = 'https://api.weixin.qq.com/cv/ocr/idcard?access_token=ACCESS_TOCKEN';
  68. return $this->callPostApi($url, $data, true);
  69. }
  70. /**
  71. * 本接口提供基于小程序的通用印刷体 OCR 识别
  72. * @param array $data
  73. * @return array
  74. * @throws \WeChat\Exceptions\InvalidResponseException
  75. * @throws \WeChat\Exceptions\LocalCacheException
  76. */
  77. public function printedText($data)
  78. {
  79. $url = 'https://api.weixin.qq.com/cv/ocr/comm?access_token=ACCESS_TOCKEN';
  80. return $this->callPostApi($url, $data, true);
  81. }
  82. /**
  83. * 本接口提供基于小程序的行驶证 OCR 识别
  84. * @param array $data
  85. * @return array
  86. * @throws \WeChat\Exceptions\InvalidResponseException
  87. * @throws \WeChat\Exceptions\LocalCacheException
  88. */
  89. public function vehicleLicense($data)
  90. {
  91. $url = 'https://api.weixin.qq.com/cv/ocr/driving?access_token=ACCESS_TOCKEN';
  92. return $this->callPostApi($url, $data, true);
  93. }
  94. }