PHP code example of greedying / zhima

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

    

greedying / zhima example snippets



use Greedying\Zhima\Foundation\Application;

$options = [
	'app_id'    => '123456',
	'scene'     => 'yourscene',
	'private_key_file' => "/dir/to/your/rsa_private_key.pem",
	'zhima_public_key_file' => "/dir/to/your/zhima_public_key.pem",
];

$zhima = new Application($options);

$open_id = '123456';
transaction_id = '234567';




$auth = $zhima->auth;
$auth->identity_type = '2';
$auth->identity_param = json_encode([
	'certNo'    => '身份证号',
	'certType'  => 'IDENTITY_CARD',
	'name'      => '名字',
]);

$auth->state = 'your state string'; //自定义字符串

$url = $auth->getH5Url();//H5授权链接
//$url = $auth->getPcUrl();//Pc授权链接

//其他暂时没有实现

$this->redirect($url); //访问授权链接,进入芝麻页面

//回调页面,传入callback函数即可,notify为已经解密的数据, successful为是否授权成功
$auth->handleNotify(callback function ($notify, $successful) {
		//your code
});

//查询是否授权
$auth->identity_type = '2';
$auth->identity_param = json_encode([
	'certNo'    => '身份证号',
	'certType'  => 'IDENTITY_CARD',
	'name'      => '名字',
]);

$auth->state = 'your state string'; //自定义字符串
$result = $auth->query(); //true or false



//只查询分数
$score = $zhima->score->score($open_id, $transaction_id); 

//查询分数信息
$score = $zhima->score->query($open_id, $transaction_id); 




$score = $zhima->watchlist->query($open_id, $transaction_id); 




$info = [
	'transaction_id'    => '',
	'open_id'           => '',
	'cert_no'           => '',
	'cert_type'         => '100',
	'name'              => '',
	'mobile'            => '',
	'email'             => '',
	'bank_card'         => '',
	'address'           => '',
	'ip'                => '',
	'mac'               => '',
	'wifimac'           => '',
	'imei'              => '',
	'imsi'              => '',
];


//只查询得分
$score = $zhima->ivs->score($open_id, $transaction_id); 

//查询相信信息
$score = $zhima->isv->query($open_id, $transaction_id);