success('提交成功', $list); } //获取店铺 public function getShop(ShopList $shopList){ $platform_id = $this->request->post('platform_id/d'); if(empty($platform_id)){ $this->error('参数有误'); } return $this->success('ok', $shopList->where('platform', $platform_id)->column('name', 'id')); } public function createAddress(){ $tx_hash = Request::post('tx_hash'); $api_url = 'http://127.0.0.1:3389/api/txDetail'; if(empty($tx_hash)){ $this->error('参数有误'); } $data = [ 'api_id' => 1, 'coin_type' => 'BEP20', 'user_no' => 1, 'time_stamp' => 1122, 'reset' => true ]; $body = $this->doCurlPostRequest($api_url, $data); //dump($body); $info = json_decode($body, true); //dump($body); //$body = $this->getInfoByTransactionHash($txhash); if($info['code'] == 200){ $this->success('', $info['data']); } $this->error($info['message']); } function doCurlPostRequest($url = '',Array $data = array()) { $data_string = json_encode($data,JSON_UNESCAPED_UNICODE); // $data_string = $data; $curl_con = curl_init(); curl_setopt($curl_con, CURLOPT_URL,$url); curl_setopt($curl_con, CURLOPT_HEADER, false); curl_setopt($curl_con, CURLOPT_POST, true); curl_setopt($curl_con, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl_con, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($curl_con, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) ); curl_setopt($curl_con, CURLOPT_POSTFIELDS, $data_string); $res = curl_exec($curl_con); $status = curl_getinfo($curl_con); curl_close($curl_con); if (isset($status['http_code']) && $status['http_code'] == 200) { return $res; } else { return FALSE; } } }