From 0e70c7fcd70bf4130b0aee091a887f9aa069b5e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Thu, 19 Sep 2024 10:53:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E5=AE=A2=E6=9C=8D=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WeMini/Custom.php | 209 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 WeMini/Custom.php diff --git a/WeMini/Custom.php b/WeMini/Custom.php new file mode 100644 index 0000000..288cd9e --- /dev/null +++ b/WeMini/Custom.php @@ -0,0 +1,209 @@ +callPostApi($url, $data, true); + } + + /** + * 更新商户信息 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function businessUpdate($data) + { + $url = 'https://api.weixin.qq.com/cgi‐bin/business/update?access_token=ACCESS_TOKEN'; + return $this->callPostApi($url, $data, true); + } + + + /** + * 拉取单个商户信息 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function businessGet($data) + { + $url = 'https://api.weixin.qq.com/cgi‐bin/business/get?access_token=ACCESS_TOKEN'; + return $this->callPostApi($url, $data, true); + } + + + /** + * 拉取多个商户信息 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function businessList($data) + { + $url = 'https://api.weixin.qq.com/cgi‐bin/business/list?access_token=ACCESS_TOKEN'; + return $this->callPostApi($url, $data, true); + } + + /** + * 发送客服消息 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function businessSend($data) + { + $url = 'https://api.weixin.qq.com/cgi‐bin/message/custom/business/send?access_token=ACCESS_TOKEN'; + return $this->callPostApi($url, $data, true); + } + + /** + * 客服输入状态 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function businessTyping($data) + { + $url = 'https://api.weixin.qq.com/cgi‐bin/message/custom/business/typing?access_token=ACCESS_TOKEN'; + return $this->callPostApi($url, $data, true); + } + + + /** + * 获取客服基本信息 + * @param string $business_id 客服子商户的business_id,对于普通小程序客服不需要填business_id + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function getKfList($business_id = '') + { + $url = 'https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token=ACCESS_TOKEN'; + if (!empty($business_id)) { + $url .= '&business_id=' . $business_id; + } + return $this->callGetApi($url); + } + + + /** + * 获取在线客服列表 + * @param string $business_id 客服子商户的business_id,对于普通小程序客服不需要填business_id + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function getOnlineKfList($business_id = '') + { + $url = 'https://api.weixin.qq.com/cgi-bin/customservice/getonlinekflist?access_token=ACCESS_TOKEN'; + if (!empty($business_id)) { + $url .= '&business_id=' . $business_id; + } + return $this->callGetApi($url); + } + + + /** + * 客服输入状态 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function addKfAccount($data) + { + $url = 'https://api.weixin.qq.com/customservice/kfaccount/add?access_token=ACCESS_TOKEN'; + return $this->callPostApi($url, $data, true); + } + + + /** + * 删除客服账号 + * @param string $kf_openid 客服openid + * @param string $business_id 客服子商户的business_id,对于普通小程序客服不需要填business_id + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function delKfAccount($kf_openid, $business_id = '') + { + $url = 'https://api.weixin.qq.com/customservice/kfaccount/del?access_token=ACCESS_TOKEN&kf_openid=' . $kf_openid; + if (!empty($business_id)) { + $url .= '&business_id=' . $business_id; + } + return $this->callGetApi($url); + } + + /** + * 设置客服管理员 + * @param string $kf_openid 客服openid + * @param string $business_id 客服子商户的business_id,对于普通小程序客服不需要填business_id + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function setKfAdmin($kf_openid, $business_id = '') + { + $url = 'https://api.weixin.qq.com/customservice/kfaccount/setadmin?access_token=ACCESS_TOKEN&kf_openid=' . $kf_openid; + if (!empty($business_id)) { + $url .= '&business_id=' . $business_id; + } + return $this->callGetApi($url); + } + + + /** + * 取消客服管理员 + * @param string $kf_openid 客服openid + * @param string $business_id 客服子商户的business_id,对于普通小程序客服不需要填business_id + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function cancelKfAdmin($kf_openid, $business_id = '') + { + $url = 'https://api.weixin.qq.com/customservice/kfaccount/canceladmin?access_token=ACCESS_TOKEN&kf_openid=' . $kf_openid; + if (!empty($business_id)) { + $url .= '&business_id=' . $business_id; + } + return $this->callGetApi($url); + } +} \ No newline at end of file