| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 | <?php/** * Alipay.php UTF-8 * 阿里云实名认证api * * @date    : 2020/3/4 10:41 * * @license 这不是一个自由软件,未经授权不许任何使用和传播。 * @author  : chenbingling <cbl@huosdk.com> * @version : HUOUNION 8.5 */namespace huoIdentify\identifyDriver\driver;use huoIdentify\identifyDriver\Driver;use huolib\status\CommonStatus;use think\Config;use think\Log;class Alipay extends Driver {    /**     * 构造函数     *     * @param array $config     */    public function __construct($config = []) {        if (empty($config)) {            $config = (array) Config::get('identify_conf.alipay');        }        $_config = array(            'appCode' => get_val($config, 'APP_CODE', ''),        );        parent::__construct($_config);    }    /**     * 获取认证     *     * 阿里云市场认证接口     * https://market.aliyun.com/products/57000002/cmapi026109.html?spm=5176.10695662.1996646101.searchclickresult.215b15faGVm5dx#sku=yuncode2010900006     */    public function identify() {        // 云市场分配的应用code        $appCode = $this->config['appCode'];        $host = "https://eid.shumaidata.com";        $path = "/eid/check";        $method = "POST";        $headers = array();        array_push($headers, "Authorization:APPCODE ".$appCode);        $querys = 'idcard='.$this->id_card.'&name='.$this->real_name;        $url = $host.$path."?".$querys;        $curl = curl_init();        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);        curl_setopt($curl, CURLOPT_URL, $url);        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);        curl_setopt($curl, CURLOPT_FAILONERROR, false);        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);        curl_setopt($curl, CURLOPT_HEADER, false);        if (1 == strpos("$".$host, "https://")) {            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);        }        $_rs_json = curl_exec($curl);        curl_close($curl);        $_rs = json_decode($_rs_json, true);        if (empty($_rs)) {            Log::write(                'line='.__LINE__.'&func='.__FUNCTION__.'&class='.__CLASS__.'¶m='.json_encode(                    array($this->config, $this->id_card, $this->real_name)                ).'&rs='.$_rs_json.'[阿里云实名认证api1]', Log::ERROR            );            $_code = CommonStatus::INVALID_PARAMS;            return $this->huoError($_code, CommonStatus::getMsg($_code));        }        if (isset($_rs['code']) && 0 != $_rs['code']) {            Log::write(                'line='.__LINE__.'&func='.__FUNCTION__.'&class='.__CLASS__.'¶m='.json_encode(                    array($this->config, $this->id_card, $this->real_name)                ).'&rs='.$_rs_json.'[阿里云实名认证api2]', Log::ERROR            );            return $this->huoError($_rs['code'], $_rs['message']);        }        if (isset($_rs['result']['res']) && 1 != $_rs['result']['res']) {            Log::write(                'line='.__LINE__.'&func='.__FUNCTION__.'&class='.__CLASS__.'¶m='.json_encode(                    array($this->config, $this->id_card, $this->real_name)                ).'&rs='.$_rs_json.'[阿里云实名认证api3]', Log::ERROR            );            $_code = CommonStatus::INNER_ERROR;            return $this->huoError($_code, $_rs['result']['description']);        }        $_code = CommonStatus::NO_ERROR;        return $this->huoSuccess($_code, CommonStatus::getMsg($_code));    }}
 |