Ocr.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | WeChatDeveloper
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://think.ctolog.com
  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. $this->registerApi($url, __FUNCTION__, func_get_args());
  33. return $this->callPostApi($url, $data, true);
  34. }
  35. /**
  36. * 本接口提供基于小程序的营业执照 OCR 识别
  37. * @param array $data
  38. * @return array
  39. * @throws \WeChat\Exceptions\InvalidResponseException
  40. * @throws \WeChat\Exceptions\LocalCacheException
  41. */
  42. public function businessLicense($data)
  43. {
  44. $url = 'https://api.weixin.qq.com/cv/ocr/bizlicense?access_token=ACCESS_TOCKEN';
  45. $this->registerApi($url, __FUNCTION__, func_get_args());
  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_TOCKEN';
  58. $this->registerApi($url, __FUNCTION__, func_get_args());
  59. return $this->callPostApi($url, $data, true);
  60. }
  61. /**
  62. * 本接口提供基于小程序的身份证 OCR 识别
  63. * @param array $data
  64. * @return array
  65. * @throws \WeChat\Exceptions\InvalidResponseException
  66. * @throws \WeChat\Exceptions\LocalCacheException
  67. */
  68. public function idcard($data)
  69. {
  70. $url = 'https://api.weixin.qq.com/cv/ocr/idcard?access_token=ACCESS_TOCKEN';
  71. $this->registerApi($url, __FUNCTION__, func_get_args());
  72. return $this->callPostApi($url, $data, true);
  73. }
  74. /**
  75. * 本接口提供基于小程序的通用印刷体 OCR 识别
  76. * @param array $data
  77. * @return array
  78. * @throws \WeChat\Exceptions\InvalidResponseException
  79. * @throws \WeChat\Exceptions\LocalCacheException
  80. */
  81. public function printedText($data)
  82. {
  83. $url = 'https://api.weixin.qq.com/cv/ocr/comm?access_token=ACCESS_TOCKEN';
  84. $this->registerApi($url, __FUNCTION__, func_get_args());
  85. return $this->callPostApi($url, $data, true);
  86. }
  87. /**
  88. * 本接口提供基于小程序的行驶证 OCR 识别
  89. * @param array $data
  90. * @return array
  91. * @throws \WeChat\Exceptions\InvalidResponseException
  92. * @throws \WeChat\Exceptions\LocalCacheException
  93. */
  94. public function vehicleLicense($data)
  95. {
  96. $url = 'https://api.weixin.qq.com/cv/ocr/driving?access_token=ACCESS_TOCKEN';
  97. $this->registerApi($url, __FUNCTION__, func_get_args());
  98. return $this->callPostApi($url, $data, true);
  99. }
  100. }