From 5877d70b6c4a00cf7d2fe0539f963fbdb05fc454 Mon Sep 17 00:00:00 2001 From: ELF <360197197@qq.com> Date: Thu, 26 Dec 2019 20:55:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=BB=E5=8A=A1=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Common/Common/extend.php | 19 +++++++++++++++++++ .../Sdk/Controller/UserController.class.php | 11 ++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Application/Common/Common/extend.php b/Application/Common/Common/extend.php index 50e7765d..e743b5d2 100644 --- a/Application/Common/Common/extend.php +++ b/Application/Common/Common/extend.php @@ -2899,3 +2899,22 @@ function post_async($url="'http://47.111.118.107:9501/game-event/recharge'", $da return true; } + +function post_task($url, $data) { + $client = new Client([ + 'base_uri' => C('TASK_URL'), + 'timeout' => 5.0, + ]); + $promise = $client->requestAsync('POST', $url, [ + 'form_params' => $data + ]); + $promise->then( + function (ResponseInterface $res) { + echo $res->getStatusCode() . PHP_EOL; + }, + function (RequestException $e) { + echo $e->getMessage() . PHP_EOL; + echo $e->getRequest()->getMethod(); + } + ); +} diff --git a/Application/Sdk/Controller/UserController.class.php b/Application/Sdk/Controller/UserController.class.php index a07e872a..10879099 100644 --- a/Application/Sdk/Controller/UserController.class.php +++ b/Application/Sdk/Controller/UserController.class.php @@ -333,13 +333,10 @@ class UserController extends BaseController ); // 通知后台 TASK_URLhttp://47.111.118.107:9501 - $url = C('TASK_URL')."/game-event/login"; - post_async($url, [ - 'form_params' => [ - 'game_id' => $user["game_id"], - 'user_id' => $user["user_id"], - 'login_time' => time() - ] + post_task('/game-event/login', [ + 'game_id' => $user["game_id"], + 'user_id' => $user["user_id"], + 'login_time' => time() ]); } else {