京东云实名认证
This commit is contained in:
@@ -2,61 +2,86 @@
|
||||
|
||||
namespace app\realname\controller;
|
||||
|
||||
use fastphp\base\Controller;
|
||||
use Jdcloud\Credentials\Credentials;
|
||||
use Jdcloud\Result;
|
||||
use Jdcloud\Cloudauth\CloudauthClient;
|
||||
use app\api\model\User;
|
||||
|
||||
class Index
|
||||
class Index extends Controller
|
||||
{
|
||||
private function getCred(){
|
||||
$ak = "JDC_A3B38E573D7404F976472FB42F52";
|
||||
$sk = "C9BAE98F49B42DA2DC02868A75AA3AD8";
|
||||
print("KEY" . $ak . " sk: " . $sk);
|
||||
$cred = new Credentials($ak, $sk);
|
||||
return $cred;
|
||||
}
|
||||
|
||||
public function test()
|
||||
public function verify()
|
||||
{
|
||||
|
||||
// $userinfo = json_decode(file_get_contents("php://input"),true);
|
||||
// dd($userinfo);
|
||||
$temp = json_decode(file_get_contents("php://input"),true);
|
||||
|
||||
$user = new User;
|
||||
$user_one_info = $user->getOne(['Id'=>$this->userinfo['UserId']]);
|
||||
$update_one = [];
|
||||
|
||||
if ($user_one_info['is_verify'] == 1){
|
||||
$data = [
|
||||
'Code'=>20000
|
||||
];
|
||||
echo json_encode($data);
|
||||
die;
|
||||
}
|
||||
if ($user_one_info['is_verify'] == 2){
|
||||
$data = [
|
||||
'Code'=>-10000
|
||||
];
|
||||
echo json_encode($data);
|
||||
die;
|
||||
}
|
||||
$flag = $user->getOne(['id_code'=>$temp['id_code'],'is_verify'=>1]);
|
||||
if($flag) {
|
||||
$data = [
|
||||
'Code'=>30000
|
||||
];
|
||||
echo json_encode($data);
|
||||
die;
|
||||
}
|
||||
|
||||
$client = new CloudauthClient([
|
||||
'credentials' => $this->getCred(),
|
||||
'version' => 'latest',
|
||||
'scheme' => 'http'
|
||||
]);
|
||||
|
||||
try{
|
||||
$res = $client->GetAliveUrl([
|
||||
'name' => '郭文涵',
|
||||
'idcard' => '410329200204060032',
|
||||
'returnUrl' => 'http://www.xxxx.wyk'
|
||||
]);
|
||||
dump($res);
|
||||
}catch (\Jdcloud\Exception\JdcloudException $e) {
|
||||
print("ERROR");
|
||||
var_dump($e->getMessage());
|
||||
$this->assertFalse(true);
|
||||
|
||||
$res = $client->GetAliveUrl([
|
||||
'name' => $temp['name'],
|
||||
'idcard' => $temp['id_code'],
|
||||
'returnUrl' => 'https://php-api.juip.com/realname/publicaction/getresult?id_code='.$temp['id_code']
|
||||
]);
|
||||
|
||||
if(isset($res['result']['code']) && $res['result']['code'] == 'ok'){
|
||||
$update_one['certify_id'] = $res['result']['token'];
|
||||
$update_one['Name'] = $temp['name'];
|
||||
$update_one['id_code'] = $temp['id_code'];
|
||||
$data['url'] = $res['result']['url'];
|
||||
if($user->updateOne(['Id'=>$this->userinfo['UserId']],$update_one)){
|
||||
$data['Code'] = 10000;
|
||||
} else {
|
||||
$data = [
|
||||
'Code'=>-10000
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$data = [
|
||||
'Code'=>-10000
|
||||
];
|
||||
}
|
||||
echo json_encode($data);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getresult() {
|
||||
$client = new CloudauthClient([
|
||||
'credentials' => $this->getCred(),
|
||||
'version' => 'latest',
|
||||
'scheme' => 'http'
|
||||
]);
|
||||
|
||||
try{
|
||||
$res = $client->GetAliveResult([
|
||||
'token' => '202405281431239af143850e49c5847a',
|
||||
]);
|
||||
dump($res);
|
||||
}catch (\Jdcloud\Exception\JdcloudException $e) {
|
||||
print("ERROR");
|
||||
var_dump($e->getMessage());
|
||||
$this->assertFalse(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
65
app/realname/controller/PublicAction.php
Normal file
65
app/realname/controller/PublicAction.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace app\realname\controller;
|
||||
|
||||
use Jdcloud\Credentials\Credentials;
|
||||
use Jdcloud\Result;
|
||||
use Jdcloud\Cloudauth\CloudauthClient;
|
||||
use app\api\model\User;
|
||||
|
||||
class PublicAction
|
||||
{
|
||||
private function getCred(){
|
||||
$ak = "JDC_A3B38E573D7404F976472FB42F52";
|
||||
$sk = "C9BAE98F49B42DA2DC02868A75AA3AD8";
|
||||
$cred = new Credentials($ak, $sk);
|
||||
return $cred;
|
||||
}
|
||||
|
||||
public function getResult() {
|
||||
|
||||
|
||||
$id_code = $_GET['id_code'];
|
||||
|
||||
$user = new User;
|
||||
$user_one_info = $user->getNewOne(['id_code'=>$id_code]);
|
||||
|
||||
|
||||
|
||||
$client = new CloudauthClient([
|
||||
'credentials' => $this->getCred(),
|
||||
'version' => 'latest',
|
||||
'scheme' => 'http'
|
||||
]);
|
||||
|
||||
try{
|
||||
$res = $client->GetAliveResult([
|
||||
'token' => $user_one_info['certify_id'],
|
||||
]);
|
||||
if ($res['result']['h5Result'] == 'ok' && $res['result']['smResult'] == 'ok' && $res['result']['rxResult'] == 'ok') {
|
||||
|
||||
|
||||
$update_one = [
|
||||
'is_verify' => 1
|
||||
];
|
||||
$user->updateOne(['Id'=>$user_one_info['Id']],$update_one);
|
||||
|
||||
echo '<h1>实名认证成功</h1></br>';
|
||||
|
||||
echo "页面将在5秒后自动跳转...</br>";
|
||||
|
||||
echo "<a href='https://www.juip.com/User/Index' />如果没有跳转,请点这里跳转</a>";
|
||||
|
||||
header("Refresh: 5; url=https://www.juip.com/User/Index");
|
||||
die;
|
||||
} else {
|
||||
echo '<h1>'.$res['result']['desc'].'</h1></br>';
|
||||
}
|
||||
}catch (\Jdcloud\Exception\JdcloudException $e) {
|
||||
print("ERROR");
|
||||
var_dump($e->getMessage());
|
||||
$this->assertFalse(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user