PHP code example of smaller_fan / b_ocr

1. Go to this page and download the library: Download smaller_fan/b_ocr library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

smaller_fan / b_ocr example snippets


'providers' => [
        SmallerFan\BaiduOcr\BaiduOcrServiceProvider::class,
    ],
    
'aliases' => [
        'BaiduOcr' => SmallerFan\BaiduOcr\BaiduOcrFacade::class,
    ],

php artisan vendor:publish

生成之后会在项目 config 文件夹中出现 baiduocr.php 配置文件

将百度OCR里的配置信息填入【APP_ID,API_KEY,SECRET_KEY】

接下来就可以使用它啦~

// new 个对象 ~ 
$ocr = new BaiduOcr();
//这个方法基于百度提供的方法,网络图片文字识别接口
//【具体根据自己所需要的业务范围使用,参考路径:b_ocr/api-php-sdk/AipOcr.php】
$res = $ocr->webImageUrl('http://*****.jpg');