PHP code example of singka / singka-hwocr

1. Go to this page and download the library: Download singka/singka-hwocr 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/ */

    

singka / singka-hwocr example snippets



// +----------------------------------------------------------------------
// | 胜家云 [ SingKa Cloud ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.singka.net All rights reserved.
// +----------------------------------------------------------------------
// | 宁波晟嘉网络科技有限公司
// +----------------------------------------------------------------------
// | Author: ShyComet <[email protected]>
// +----------------------------------------------------------------------
namespace app\home\controller;

use SingKa\HwOcr\HwOcr;

class Index extends Base
{
    /**
    * OCR文字识别示例
    *
    * @appKey       华为云appKey
    * @appSecret    华为云appSecret
    * @regionName   资源所在区域
    */
    public function ocrDemo()
    {
        $config['appKey'] = 'YXMWB********PKZY';
        $config['appSecret'] = 'wC2*em*7*********EDP';
        $config['regionName'] = 'cn-north-4';
        //分别传入配置、OCR识别类型、图片地址或Base64码和其他参数
        $result = HwOcr::AkskRequest($config, 'business-license', 'http://tuoxing.shop/ocr/data/business-license-demo.jpg', []);
        return json(json_decode($result, true));
    }
  
}