- 增加支持获取配置文件的信息

v6 v6.0.23
Chaim 4 years ago
parent 590fcd56cb
commit 4fa69e6998

@ -42,5 +42,12 @@ return [
// 联盟分配给应用的secretkey // 联盟分配给应用的secretkey
'secret_key' => '', 'secret_key' => '',
] ]
],
// 宝塔
'bt' => [
// 密钥
'key' => '',
// 网址
'panel' => '',
] ]
]; ];

@ -149,6 +149,17 @@ class UnionService extends Service
$this->output = $result; $this->output = $result;
} }
/**
* 获取配置信息
* @return $this
*/
private function getConfig()
{
$this->app_key = config('dtapp.jd.union.app_key');
$this->secret_key = config('dtapp.jd.union.secret_key');
return $this;
}
/** /**
* 网站/APP获取推广链接接口 * 网站/APP获取推广链接接口
* https://union.jd.com/openplatform/api/10421 * https://union.jd.com/openplatform/api/10421
@ -314,7 +325,7 @@ class UnionService extends Service
{ {
//首先检测是否支持curl //首先检测是否支持curl
if (!extension_loaded("curl")) throw new CurlException('请开启curl模块', E_USER_DEPRECATED); if (!extension_loaded("curl")) throw new CurlException('请开启curl模块', E_USER_DEPRECATED);
$this->app_key = empty($this->app_key) ? config('dtapp.jd.union.app_key') : $this->app_key; if (empty($this->app_key)) $this->getConfig();
if (empty($this->app_key)) throw new JdException('请检查app_key参数'); if (empty($this->app_key)) throw new JdException('请检查app_key参数');
if (empty($this->method)) throw new JdException('请检查method参数'); if (empty($this->method)) throw new JdException('请检查method参数');
$this->params['method'] = $this->method; $this->params['method'] = $this->method;
@ -337,7 +348,7 @@ class UnionService extends Service
*/ */
private function createSign() private function createSign()
{ {
$this->secret_key = empty($this->secret_key) ? config('dtapp.jd.union.secret_key') : $this->secret_key; if (empty($this->secret_key)) $this->getConfig();
if (empty($this->secret_key)) throw new JdException('请检查secret_key参数'); if (empty($this->secret_key)) throw new JdException('请检查secret_key参数');
$sign = $this->secret_key; $sign = $this->secret_key;

@ -142,6 +142,17 @@ class JinBaoService extends Service
return $this; return $this;
} }
/**
* 获取配置信息
* @return $this
*/
private function getConfig()
{
$this->client_id = config('dtapp.pinduoduo.jinbao.client_id');
$this->client_secret = config('dtapp.pinduoduo.jinbao.client_secret');
return $this;
}
/** /**
* 获取商品信息 - 多多进宝商品查询 * 获取商品信息 - 多多进宝商品查询
* https://jinbao.pinduoduo.com/third-party/api-detail?apiName=pdd.ddk.goods.search * https://jinbao.pinduoduo.com/third-party/api-detail?apiName=pdd.ddk.goods.search
@ -404,10 +415,8 @@ class JinBaoService extends Service
{ {
//首先检测是否支持curl //首先检测是否支持curl
if (!extension_loaded("curl")) throw new CurlException('请开启curl模块', E_USER_DEPRECATED); if (!extension_loaded("curl")) throw new CurlException('请开启curl模块', E_USER_DEPRECATED);
$this->client_id = empty($this->client_id) ? config('dtapp.pinduoduo.jinbao.client_id') : $this->client_id; if (empty($this->client_id)) $this->getConfig();
$this->client_secret = empty($this->client_secret) ? config('dtapp.pinduoduo.jinbao.client_secret') : $this->client_secret;
if (empty($this->client_id)) throw new PinDouDouException('请检查client_id参数'); if (empty($this->client_id)) throw new PinDouDouException('请检查client_id参数');
if (empty($this->client_secret)) throw new PinDouDouException('请检查client_secret参数');
$this->param['type'] = $this->type; $this->param['type'] = $this->type;
$this->param['client_id'] = $this->client_id; $this->param['client_id'] = $this->client_id;
$this->param['timestamp'] = time(); $this->param['timestamp'] = time();
@ -438,7 +447,7 @@ class JinBaoService extends Service
*/ */
private function createSign() private function createSign()
{ {
$this->client_secret = empty($this->client_secret) ? config('dtapp.pinduoduo.jinbao.client_secret') : $this->client_secret; if (empty($this->client_secret)) $this->getConfig();
if (empty($this->client_secret)) throw new PinDouDouException('请检查client_secret参数'); if (empty($this->client_secret)) throw new PinDouDouException('请检查client_secret参数');
$sign = $this->client_secret; $sign = $this->client_secret;

@ -135,6 +135,17 @@ class TbkService extends Service
return $this; return $this;
} }
/**
* 获取配置信息
* @return $this
*/
private function getConfig()
{
$this->app_key = config('dtapp.taobao.tbk.app_key');
$this->app_secret = config('dtapp.taobao.tbk.app_secret');
return $this;
}
/** /**
* 订单查询 - 淘宝客-推广者-所有订单查询 * 订单查询 - 淘宝客-推广者-所有订单查询
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=40173&docType=2 * https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=40173&docType=2
@ -458,7 +469,7 @@ class TbkService extends Service
//首先检测是否支持curl //首先检测是否支持curl
if (!extension_loaded("curl")) throw new CurlException('请开启curl模块', E_USER_DEPRECATED); if (!extension_loaded("curl")) throw new CurlException('请开启curl模块', E_USER_DEPRECATED);
$this->format = "json"; $this->format = "json";
$this->app_key = empty($this->app_key) ? config('dtapp.taobao.tbk.app_key') : $this->app_key; if (empty($this->app_key)) $this->getConfig();
if (empty($this->app_key)) throw new TaoBaoException('请检查app_key参数'); if (empty($this->app_key)) throw new TaoBaoException('请检查app_key参数');
if (empty($this->method)) throw new TaoBaoException('请检查method参数'); if (empty($this->method)) throw new TaoBaoException('请检查method参数');
$this->param['app_key'] = $this->app_key; $this->param['app_key'] = $this->app_key;
@ -514,7 +525,7 @@ class TbkService extends Service
*/ */
private function createSign() private function createSign()
{ {
$this->app_secret = empty($this->app_secret) ? config('dtapp.taobao.tbk.app_secret') : $this->app_secret; if (empty($this->app_secret)) $this->getConfig();
if (empty($this->app_secret)) throw new TaoBaoException('请检查app_secret参数'); if (empty($this->app_secret)) throw new TaoBaoException('请检查app_secret参数');
$sign = $this->app_secret; $sign = $this->app_secret;

@ -16,6 +16,7 @@
namespace DtApp\ThinkLibrary\service\bt; namespace DtApp\ThinkLibrary\service\bt;
use DtApp\ThinkLibrary\exception\BtException;
use DtApp\ThinkLibrary\exception\CurlException; use DtApp\ThinkLibrary\exception\CurlException;
use DtApp\ThinkLibrary\Service; use DtApp\ThinkLibrary\Service;
use DtApp\ThinkLibrary\service\Curl\BtService; use DtApp\ThinkLibrary\service\Curl\BtService;
@ -49,6 +50,17 @@ class ApiService extends Service
return $this; return $this;
} }
/**
* 获取配置信息
* @return $this
*/
private function getConfig()
{
$this->key = config('dtapp.bt.key');
$this->panel = config('dtapp.bt.panel');
return $this;
}
/** /**
* 获取监控信息 * 获取监控信息
* @param string $type 类型 GetCpuIo = CPU信息/内存 GetDiskIo = 磁盘IO GetNetWorkIo = 网络IO * @param string $type 类型 GetCpuIo = CPU信息/内存 GetDiskIo = 磁盘IO GetNetWorkIo = 网络IO
@ -317,7 +329,7 @@ class ApiService extends Service
/** /**
* 发起网络请求 * 发起网络请求
* @return $this * @return $this
* @throws CurlException * @throws CurlException|BtException
*/ */
private function getHttp() private function getHttp()
{ {
@ -365,10 +377,12 @@ class ApiService extends Service
* @param array $data 数据 * @param array $data 数据
* @param bool $is_json 是否返回Json格式 * @param bool $is_json 是否返回Json格式
* @return bool|mixed|string * @return bool|mixed|string
* @throws CurlException * @throws CurlException|BtException
*/ */
protected function HttpPostCookie(string $url, array $data = [], bool $is_json = true) protected function HttpPostCookie(string $url, array $data = [], bool $is_json = true)
{ {
if (empty($this->panel)) $this->getConfig();
if (empty($this->panel)) throw new BtException('请检查panel参数');
//定义cookie保存位置 //定义cookie保存位置
$file = app()->getRootPath() . 'runtime/dtapp/bt/cookie/'; $file = app()->getRootPath() . 'runtime/dtapp/bt/cookie/';
$cookie_file = $file . md5($this->panel) . '.cookie'; $cookie_file = $file . md5($this->panel) . '.cookie';
@ -377,6 +391,8 @@ class ApiService extends Service
$fp = fopen($cookie_file, 'w+'); $fp = fopen($cookie_file, 'w+');
fclose($fp); fclose($fp);
} }
if (empty($this->key)) $this->getConfig();
if (empty($this->key)) throw new BtException('请检查key参数');
return BtService::instance() return BtService::instance()
->panel($this->panel) ->panel($this->panel)
->key($this->key) ->key($this->key)

Loading…
Cancel
Save