From 4087b54f2bc9df73e6a528ed17977440311bc4da Mon Sep 17 00:00:00 2001 From: 何书鹏 <heshupeng@bronet.cn> Date: Tue, 22 Feb 2022 14:12:10 +0800 Subject: [PATCH] 测试 --- application/api/controller/User.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/application/api/controller/User.php b/application/api/controller/User.php index ea9beda..f601194 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -8,6 +8,7 @@ use app\api\model\UserCoupon; use app\common\controller\Api; use EasyWeChat\Factory; use fast\Http; +use GuzzleHttp\Client; use think\Config; use think\Db; use think\Validate; @@ -820,21 +821,14 @@ class User extends Api * 测试 */ public function ceshi(){ - $push_api_url = request()->domain().":2121/"; - $post_data = array( - 'type' => 'publish', - 'content' => '这个是推送的测试数据', - 'to' => '', - ); - $ch = curl_init (); - curl_setopt ( $ch, CURLOPT_URL, $push_api_url ); - curl_setopt ( $ch, CURLOPT_POST, 1 ); - curl_setopt ( $ch, CURLOPT_HEADER, 0 ); - curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); - curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post_data ); - curl_setopt ( $ch, CURLOPT_HTTPHEADER, array("Expect:")); - $return = curl_exec ( $ch ); - curl_close ( $ch ); - halt($return); + $client = new Client(); + $response = $client->request('POST', request()->domain().":2121/", [ + 'form_params' => [ + 'type' => 'publish', + 'content' => '这个是推送的测试数据', + 'to' => '', + ] + ]); + halt($response->getBody()->getContents()); } } -- libgit2 0.24.0