Browse Source

新增数据返回接口

master
wanghongjun 3 years ago
parent
commit
31749237a4
  1. 6
      source/application/api/controller/Controller.php
  2. 26
      source/application/api/controller/stadium/Param.php
  3. 19
      source/application/config.php

6
source/application/api/controller/Controller.php

@ -26,8 +26,10 @@ class Controller extends \think\Controller
*/ */
public function _initialize() public function _initialize()
{ {
header("Access-Control-Allow-Origin: http://192.168.66.220:8080"); $config = config('api_config');
header("Access-Control-Allow-Origin: http://192.168.66.220:8081"); foreach ($config['access_control_allow_origin'] as $value) {
header("Access-Control-Allow-Origin: ".$value);
}
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE"); header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE");
header("Access-Control-Allow-Headers: Content-Type"); header("Access-Control-Allow-Headers: Content-Type");
header("Access-Control-Allow-Credentials: true"); header("Access-Control-Allow-Credentials: true");

26
source/application/api/controller/stadium/Param.php

@ -0,0 +1,26 @@
<?php
namespace app\api\controller\stadium;
use app\api\controller\Controller;
class Param extends Controller
{
public function paramInfo()
{
$config = config('api_config');
$returnArr = [
'host' => $config['host'],
'port' => $config['port'],
'appkey' => $config['cid'],
'secret' => $config['cskey']
];
$base64 = base64_encode(json_encode($returnArr)) . "==";
$base64Two = base64_encode($base64);
return $this->renderSuccess(compact('base64Two'));
}
}

19
source/application/config.php

@ -243,11 +243,24 @@ return [
// | 自定义配置 // | 自定义配置
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
'api_config' => [ 'api_config' => [
// 调用网址地址 # 调用网址地址
'host_url' => 'https://192.168.66.13:443/artemis', 'host' => '192.168.66.13',
# 端口号
'port' => '443', 'port' => '443',
# 请求key
'cid' => '29940726', 'cid' => '29940726',
# 请求密钥
'cskey' => 'SkTCnQdFbNW4Z2suNj8P', 'cskey' => 'SkTCnQdFbNW4Z2suNj8P',
'host_path' => 'http://btgym.xingtongworld.com/index.php?s=' # 请求智慧景区接口地址
'host_url' => 'https://192.168.66.13:443/artemis',
# 脚本数据推送创建数据地址
//'host_path' => 'http://btgym.xingtongworld.com/index.php?s='
'host_path' => 'http://192.168.66.16/index.php?s=',
// 'host_path' => 'http://www.stadium.com/index.php?s='
# 允许跨域 请求的IP地址
'access_control_allow_origin' => [
'http://192.168.66.220:8080',
'http://192.168.66.220:8081'
]
] ]
]; ];

Loading…
Cancel
Save