$op, 'task' => $task, 'version' => $version, 'appid' => config('console.thirdScale.appid') ]; //密钥 $sign = $this->sign($fixedParameter['op'], $fixedParameter['task'], $fixedParameter['version'], $parameter); //加入 $fixedParameter['sign'] = $sign; return $fixedParameter; } public function getScale(int $start, int $count, string $keyword) { //请求参数 $parameter = ['start'=>$start, 'count'=>$count, 'keyword'=>$keyword]; //固定参数 $fixedParameter = $this->fixedParameter('module', 'moduleList', $parameter); //请求地址 $url = config('console.thirdScale.url'); try { $parameter = array_merge($fixedParameter, $parameter); $client = new httpClient(); $res = $client->request('post', $url, ['form_params'=>$parameter]); $body = $res->getBody(); $data = json_decode($body); return $this->response($data); } catch (\Exception $e) { $this->setLog(self::TYPENAME.'getAccessToken 远程请求失败', $this->startTime, [$e->getMessage()]); $this->error()->fail(); } } public function createPush(string $openid, string $mid) { //请求参数 $parameter = ['open_id'=>$openid, 'mid'=>$mid]; //固定参数 $fixedParameter = $this->fixedParameter('module', 'createPush', $parameter); //请求地址 $url = config('console.thirdScale.url'); try { $parameter = array_merge($fixedParameter, $parameter); $client = new httpClient(); $res = $client->request('post', $url, ['form_params'=>$parameter]); $body = $res->getBody(); $data = json_decode($body); $this->setLog(self::TYPENAME.'createPush 远程请求结果', $this->startTime, [$parameter]); $this->setLog(self::TYPENAME.'createPush 远程请求结果', $this->startTime, [$url]); $this->setLog(self::TYPENAME.'createPush 远程请求结果', $this->startTime, [$data]); return $data->data->push_id; // return $this->response($data); } catch (\Exception $e) { $this->setLog(self::TYPENAME.'createPush 远程请求失败', $this->startTime, [$e->getMessage()]); $this->error()->fail(); } } public function customerCreate(string $name, string $openId = null, int $sex = 1) { //请求参数 // $parameter = ['name'=>$openId]; $parameter = [ 'name'=>$name, 'wechat_uid'=>$openId, ]; //固定参数 $fixedParameter = $this->fixedParameter('customer', 'customerCreate', $parameter); //请求地址 $url = config('console.thirdScale.url'); try { $parameter = array_merge($fixedParameter, $parameter); $client = new httpClient(); $res = $client->request('post', $url, ['form_params'=>$parameter]); $body = $res->getBody(); $data = json_decode($body); self::setLog(self::TYPENAME.'customerCreate 远程返回结果', $this->startTime, [$data]); // echo json_encode($url); // echo json_encode($parameter); // echo "
"; // echo json_encode($data); exit; return $data->data->open_id; // return $this->response($data); } catch (\Exception $e) { $this->setLog(self::TYPENAME.'customerCreate 远程请求失败', $this->startTime, [$e->getMessage()]); $this->error()->fail($e->getMessage()); } } public function appLogin(string $thirdOpenId, string $pushId, string $reportId) { //请求参数 if ($pushId){ //$parameter = ['appid'=>config('console.thirdScale.appid'), 'push_id'=>$pushId, 'open_id'=>$thirdOpenId, 'version'=>'1.0.0']; $parameter = ['appid'=>config('console.thirdScale.appid'), 'push_id'=>$pushId, 'open_id'=>$thirdOpenId, 'version'=>'1.1.0', 'is_report'=>'1', 's_timestamp'=>time()]; } if ($reportId){ $parameter = ['report_id'=>$reportId, 'open_id'=>$thirdOpenId]; } //$parameter['sign'] = $this->sign('core', 'appLogin', '1.0.0', ['push_id'=>$pushId, 'open_id'=>$thirdOpenId]); $parameter['sign'] = $this->sign('core', 'appLogin', '1.1.0', ['push_id'=>$pushId, 'open_id'=>$thirdOpenId, 'is_report'=>'1', 's_timestamp'=>time()]); $str = ''; foreach ($parameter as $key=>$v){ $str.=$key.'='.urlencode($v).'&'; } //请求地址 $url = config('console.thirdScale.do_url'); return $url.'&'.$str; } }