43 lines
1.5 KiB
PHP
43 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace web\admin\demo\dyn;
|
|
|
|
class callapi {
|
|
public static function json_gettoken() {
|
|
$post = new \ciy\post();
|
|
$apiid = $post->getint('apiid');
|
|
if (empty($apiid))
|
|
return errjson('请输入apiid');
|
|
$apikey = $post->get('apikey');
|
|
if (empty($apikey))
|
|
return errjson('请输入apikey');
|
|
$param = array();
|
|
$param['apiid'] = $apiid;
|
|
$param['apitime'] = time();
|
|
$param['sign'] = hash('sha256', $apiid . '&' . $param['apitime'] . '&' . $apikey);
|
|
$http = new \ciy\http();
|
|
$http->request('https://ciyon.local.ciy.cn/admin/login.gettoken', json_encode($param));
|
|
$datastr = $http->get_data();
|
|
$data = json_decode($datastr, true);
|
|
if ($data === null)
|
|
return errjson('API返回错误:' . $datastr);
|
|
return succjson($data);
|
|
}
|
|
public static function json_call1() {
|
|
$post = new \ciy\post();
|
|
$token = $post->get('token');
|
|
if (empty($token))
|
|
return errjson('请输入token');
|
|
$param = array();
|
|
$param['query'] = array('liid' => 10);
|
|
$http = new \ciy\http();
|
|
$http->set_header('CIYAUTH', $token);
|
|
$http->request('https://ciyon.local.ciy.cn/admin/rigger/admin.init', json_encode($param));
|
|
$datastr = $http->get_data();
|
|
$data = json_decode($datastr, true);
|
|
if ($data === null)
|
|
return errjson('API返回错误:' . $datastr);
|
|
return succjson($data);
|
|
}
|
|
}
|