From b3dfdc6e6b3a6eaa3b72ad7da54a98bbfc1b095f Mon Sep 17 00:00:00 2001 From: chujiu Date: Thu, 27 Dec 2018 15:46:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=91=E5=AE=9A=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E7=94=A8=E6=88=B7=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/PdAuth/OAuth.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/PdAuth/OAuth.php b/src/PdAuth/OAuth.php index fdf913e..a01303c 100644 --- a/src/PdAuth/OAuth.php +++ b/src/PdAuth/OAuth.php @@ -85,6 +85,29 @@ class OAuth return null; } + + /** + * @绑定好物平台用户 + * + * @param int $user_id + * @param int $hwuser_id + * @return null + */ + public function bindHwUser(int $user_id, int $hwuser_id) + { + if ($user_id <= 0 || $hwuser_id <= 0) { + return null; + } + $resp = $this->post("$this->host/api/bind/hwuser", [ + 'id' => $user_id, + 'hwmc_id' => $hwuser_id, + ]); + if ($resp['code'] == 0) { + return $resp['data']; + } + return null; + } + /** * 对 pd auth 系统发起请求 * @param $url @@ -102,4 +125,25 @@ class OAuth } } + /** + * 对 pd auth 系统发起post请求 + * + * @param $url + * @param array $params + * @param array $headers + * @return null + */ + protected function post($url, $params = [], $headers = []) + { + $client = new \GuzzleHttp\Client(); + $res = $client->request('POST', $url, [ + 'headers' => $headers, + 'form_params' => $params, + ]); + if ($res->getStatusCode() == 200) { + return \GuzzleHttp\json_decode($res->getBody(), true); + } else { + return null; + } + } } \ No newline at end of file