Ocr.php 3.5 KB

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