From a4a791e59948baf12609b32b6cd240390a43cb77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cwanyongkang=E2=80=9D?= <“937888580@qq.com”> Date: Wed, 12 May 2021 16:22:35 +0800 Subject: [PATCH] =?UTF-8?q?api=E6=8E=A5=E5=8F=A3=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Account.php | 174 +++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 app/api/controller/Account.php diff --git a/app/api/controller/Account.php b/app/api/controller/Account.php new file mode 100644 index 0000000..c1f9dfa --- /dev/null +++ b/app/api/controller/Account.php @@ -0,0 +1,174 @@ + $data['apikey'], + "ProductId" => $data['product'], + "PackageId" => $data['package'], + "Account" => $data['account'], + "Pwd" => $data['pwd'], + ); + + $data_string = json_encode($params); + + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json', + 'Content-Length: ' . strlen($data_string)) + ); + + $result = curl_exec($ch); + + echo $result; + } + + //通过接口开正式账号 + // /api/account/createAccount?apikey=1232455165&package=17&account=test123211&pwd=123&connect=1&orderType=1 + public function createAccount() + { + //获取传递的数据 + $data = $_GET; + $url = 'http://www.juip.com/product/ApiCreateOrder'; + + $params = array( + "apikey" => $data['apikey'], + "PackageId" => $data['package'], + "Account" => $data['account'], + "Pwd" => $data['pwd'], + "ConnectCount" =>$data['connect'], + "OrderType" => $data['type'], + "OPayType" => '100', + "PayChannel" => '50', + "UseAccountAmount" => '1', + ); + + $data_string = json_encode($params); + + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json', + 'Content-Length: ' . strlen($data_string)) + ); + + $result = curl_exec($ch); + + echo $result; + } + + //通过接口更改账号密码 + public function updateAccountPwd() + { + //获取传递的数据 + $data = $_GET; + $url = 'http://www.juip.com/user/ApiUpdateAccountPwd'; + + $params = array( + "apikey" => $data['apikey'], + "Account" => $data['account'], + "Pwd" => $data['pwd'], + "RePwd" => $data['newPwd'], + ); + + $data_string = json_encode($params); + + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json', + 'Content-Length: ' . strlen($data_string)) + ); + + $result = curl_exec($ch); + + echo $result; + } + + //获取账号在线状态 + public function onLine() + { + //获取传递的数据 + $data = $_GET; + $url = 'http://www.juip.com/api/course/v1/productaccount/OnLine?productId='.$data['product'].'&account='.$data['account']; + + $apikey = $data['apikey']; + $user_model = new User; + $user_info = $user_model->getOne(['apikey'=>$apikey]); + if (empty($user_info)){ + $data = [ + 'Code' => 0, + 'Message' => 'apikey不符合规范', + ]; + echo json_encode($data); + die; + } + + + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json' + ) + ); + + $result = curl_exec($ch); + + echo $result; + } + + //踢线 + public function killOut() + { + //获取传递的数据 + $data = $_GET; + $url = 'http://www.juip.com/api/course/v1/productaccount/KillOut?productId='.$data['product'].'&id='.$data['id']; + + $apikey = $data['apikey']; + $user_model = new User; + $user_info = $user_model->getOne(['apikey'=>$apikey]); + if (empty($user_info)){ + $data = [ + 'Code' => 0, + 'Message' => 'apikey不符合规范', + ]; + echo json_encode($data); + die; + } + + + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json' + ) + ); + + $result = curl_exec($ch); + + echo $result; + } +} \ No newline at end of file