user = User::find(3); $ret = [ 'redemptionCode' => '951117396307', 'total' => 5, 'outletId' => '2004011649602', ]; return $this->success($ret); dd(); $jsonData = json_encode($ret); //数据JSON化 $ascdata = $this->keyasc($jsonData); //加密 $addcode = sprintf("%08d", mt_rand(0, 99999999)); //随机code 验证签名用 $sign = $this->keysign($ascdata, $addcode); $data = [ 'server_id' => $this->user->server_id, 'key' => $this->user->server_key, 'addcode' => $addcode, 'sign' => $sign, 'data' => $ascdata, ]; $res = self::http($data); dd($res); } public function http($data) { $client = new Client(); $response = $client->request('POST', 'http://pa.ysd-bs.com/api/V1/user/freezecoupon', ['form_params' => $data, 'http_errors' => false]); $body = $response->getBody(); $content = $body->getContents(); dump($content); $result = json_decode($content, true); return $result; } }