Commit 7f75b8ef authored by 朱招明's avatar 朱招明

update

parent d94aa816
<?php <?php
return [ return [
'app_key' => '1085616747', 'app_key' => 'app_key',
'app_secret' => '6fc630bcedc5e65a3fc37363d7dd2e4f', 'app_secret' => 'app_secret',
]; ];
\ No newline at end of file
...@@ -12,5 +12,5 @@ $params = [ ...@@ -12,5 +12,5 @@ $params = [
'change' => 0, 'change' => 0,
]; ];
$result = $Power->pushOrder($params); $result = $Power->pushOrder($params);
var_dump(json_decode($result)); var_dump($result);
...@@ -13,6 +13,18 @@ use Illuminate\Support\ServiceProvider; ...@@ -13,6 +13,18 @@ use Illuminate\Support\ServiceProvider;
class ThirdApiServiceProvider extends ServiceProvider class ThirdApiServiceProvider extends ServiceProvider
{ {
/** /**
* 在注册后进行服务的启动。
*
* @return void
*/
public function boot()
{
if ($this->app->runningInConsole()) {
$this->publishes([__DIR__.'/../config' => config_path()], 'third-api');
}
}
/**
* 在服务容器里注册 * 在服务容器里注册
* *
* @return void * @return void
...@@ -20,6 +32,5 @@ class ThirdApiServiceProvider extends ServiceProvider ...@@ -20,6 +32,5 @@ class ThirdApiServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->mergeConfigFrom(realpath(__DIR__.'/../config/wike.php'), 'wike'); $this->mergeConfigFrom(realpath(__DIR__.'/../config/wike.php'), 'wike');
} }
} }
\ No newline at end of file
...@@ -8,14 +8,20 @@ ...@@ -8,14 +8,20 @@
namespace SMG\ThirdApi\WeiKe; namespace SMG\ThirdApi\WeiKe;
use SMG\ThirdApi\WeiKe\Rest\Power;
class Base class Base
{ {
protected $base_uri = 'https://router.wikeyun.cn/'; protected $base_uri = 'https://router.wikeyun.cn/';
protected $config = []; protected $config = [];
public function __construct() { public function __construct($config=null) {
if($config){
$this->config = $config;
}else{
$this->config = config('wike'); $this->config = config('wike');
}
if(empty($this->config['app_key'])){ if(empty($this->config['app_key'])){
throw new \Exception("缺少 app_key"); throw new \Exception("缺少 app_key");
} }
...@@ -35,7 +41,7 @@ class Base ...@@ -35,7 +41,7 @@ class Base
* @since 2023/10/14 * @since 2023/10/14
* @modify * @modify
*/ */
public function getSign($params){ protected function getSign($params){
$str = ''; $str = '';
#首字母以ASCII方式升序排列 #首字母以ASCII方式升序排列
......
...@@ -48,7 +48,8 @@ class Power extends Base ...@@ -48,7 +48,8 @@ class Power extends Base
'form_params' => $params, 'form_params' => $params,
]); ]);
if ($response->getStatusCode() === 200) { if ($response->getStatusCode() === 200) {
return $response->getBody()->getContents(); $body = $response->getBody()->getContents();
return json_decode($body);
} else { } else {
throw new \Exception("请求失败,状态码:{$response->getStatusCode()}"); throw new \Exception("请求失败,状态码:{$response->getStatusCode()}");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment