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

update

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