diff --git a/WeMini/Crypt.php b/WeMini/Crypt.php index 70081ed..a458d7b 100644 --- a/WeMini/Crypt.php +++ b/WeMini/Crypt.php @@ -50,6 +50,7 @@ class Crypt extends BasicWeChat * 登录凭证校验 * @param string $code 登录时获取的 code * @return array + * @throws \WeChat\Exceptions\LocalCacheException */ public function session($code) { @@ -67,6 +68,7 @@ class Crypt extends BasicWeChat * @return array * @throws InvalidDecryptException * @throws InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException */ public function userInfo($code, $iv, $encryptedData) { @@ -80,4 +82,24 @@ class Crypt extends BasicWeChat } return array_merge($result, $userinfo); } + + /** + * 用户支付完成后,获取该用户的 UnionId + * @param string $openid 支付用户唯一标识 + * @param null|string $transaction_id 微信支付订单号 + * @param null|string $mch_id 微信支付分配的商户号,和商户订单号配合使用 + * @param null|string $out_trade_no 微信支付商户订单号,和商户号配合使用 + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function getPaidUnionId($openid, $transaction_id = null, $mch_id = null, $out_trade_no = null) + { + $url = "https://api.weixin.qq.com/wxa/getpaidunionid?access_token=ACCESS_TOKEN&openid={$openid}"; + if (is_null($mch_id)) $url .= "&mch_id={$mch_id}"; + if (is_null($out_trade_no)) $url .= "&out_trade_no={$out_trade_no}"; + if (is_null($transaction_id)) $url .= "&transaction_id={$transaction_id}"; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callGetApi($url); + } } \ No newline at end of file diff --git a/WeMini/Delivery.php b/WeMini/Delivery.php new file mode 100644 index 0000000..ce7bcb4 --- /dev/null +++ b/WeMini/Delivery.php @@ -0,0 +1,209 @@ +registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 下配送单接口 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function addOrder($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/add?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 可以对待接单状态的订单增加小费 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function addTip($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/addtips?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 取消配送单接口 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function cancelOrder($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/cancel?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 获取已支持的配送公司列表接口 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function getAllImmeDelivery($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/delivery/getall?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 拉取已绑定账号 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function getBindAccount($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/shop/get?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 拉取配送单信息 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function getOrder($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/get?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 模拟配送公司更新配送单状态 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function mockUpdateOrder($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/test_update_order?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 预下配送单接口 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function preAddOrder($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/pre_add?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 预取消配送单接口 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function preCancelOrder($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/precancel?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 重新下单 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function reOrder($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/local/business/order/readd?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 动态消息,创建被分享动态消息的 activity_id + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function createActivityId($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/activityid/create?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 动态消息,修改被分享的动态消息 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function setUpdatableMsg($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/updatablemsg/send?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + +} \ No newline at end of file diff --git a/WeMini/Img.php b/WeMini/Img.php new file mode 100644 index 0000000..5fc01c2 --- /dev/null +++ b/WeMini/Img.php @@ -0,0 +1,72 @@ +registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, ['img_url' => $img_url, 'img' => $img], true); + } + + /** + * 本接口提供基于小程序的条码/二维码识别的API + * @param string $img_url 要检测的图片 url,传这个则不用传 img 参数。 + * @param string $img form-data 中媒体文件标识,有filename、filelength、content-type等信息,传这个则不用穿 img_url + * @return array + * @throws InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function scanQRCode($img_url, $img) + { + $url = "https://api.weixin.qq.com/cv/img/qrcode?img_url=ENCODE_URL&access_token=ACCESS_TOCKEN"; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, ['img_url' => $img_url, 'img' => $img], true); + } + + /** + * 本接口提供基于小程序的图片高清化能力 + * @param string $img_url 要检测的图片 url,传这个则不用传 img 参数 + * @param string $img form-data 中媒体文件标识,有filename、filelength、content-type等信息,传这个则不用穿 img_url + * @return array + * @throws InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function superresolution($img_url, $img) + { + $url = "https://api.weixin.qq.com/cv/img/qrcode?img_url=ENCODE_URL&access_token=ACCESS_TOCKEN"; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, ['img_url' => $img_url, 'img' => $img], true); + } +} \ No newline at end of file diff --git a/WeMini/Logistics.php b/WeMini/Logistics.php new file mode 100644 index 0000000..dc048bb --- /dev/null +++ b/WeMini/Logistics.php @@ -0,0 +1,206 @@ +registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 取消运单 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function cancelOrder($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/business/order/cancel?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 获取支持的快递公司列表 + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function getAllDelivery() + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/business/delivery/getall?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callGetApi($url); + } + + /** + * 获取运单数据 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function getOrder($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/business/order/get?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 查询运单轨迹 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function getPath($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/business/path/get?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 获取打印员。若需要使用微信打单 PC 软件,才需要调用 + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function getPrinter() + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/business/printer/getall?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callGetApi($url); + } + + /** + * 获取电子面单余额。仅在使用加盟类快递公司时,才可以调用 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function getQuota($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/business/path/get?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 模拟快递公司更新订单状态, 该接口只能用户测试 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function testUpdateOrder($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/business/test_update_order?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 配置面单打印员,若需要使用微信打单 PC 软件,才需要调用 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function updatePrinter($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/business/printer/update?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 获取面单联系人信息 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function getContact($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/contact/get?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 预览面单模板。用于调试面单模板使用 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function previewTemplate($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/template/preview?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 更新商户审核结果 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function updateBusiness($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/service/business/update?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 更新运单轨迹 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function updatePath($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/path/update?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + +} \ No newline at end of file diff --git a/WeMini/Ocr.php b/WeMini/Ocr.php new file mode 100644 index 0000000..22b5048 --- /dev/null +++ b/WeMini/Ocr.php @@ -0,0 +1,110 @@ +registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 本接口提供基于小程序的营业执照 OCR 识别 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function businessLicense($data) + { + $url = 'https://api.weixin.qq.com/cv/ocr/bizlicense?access_token=ACCESS_TOCKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 本接口提供基于小程序的驾驶证 OCR 识别 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function driverLicense($data) + { + $url = 'https://api.weixin.qq.com/cv/ocr/drivinglicense?access_token=ACCESS_TOCKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 本接口提供基于小程序的身份证 OCR 识别 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function idcard($data) + { + $url = 'https://api.weixin.qq.com/cv/ocr/idcard?access_token=ACCESS_TOCKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 本接口提供基于小程序的通用印刷体 OCR 识别 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function printedText($data) + { + $url = 'https://api.weixin.qq.com/cv/ocr/comm?access_token=ACCESS_TOCKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + /** + * 本接口提供基于小程序的行驶证 OCR 识别 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function vehicleLicense($data) + { + $url = 'https://api.weixin.qq.com/cv/ocr/driving?access_token=ACCESS_TOCKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + +} \ No newline at end of file diff --git a/WeMini/Plugs.php b/WeMini/Plugs.php index 4755ff1..6110e89 100644 --- a/WeMini/Plugs.php +++ b/WeMini/Plugs.php @@ -64,6 +64,20 @@ class Plugs extends BasicWeChat return $this->callPostApi($url, ['action' => 'unbind', 'plugin_appid' => $plugin_appid], true); } + /** + * 获取当前所有插件使用方 + * 修改插件使用申请的状态 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function devplugin($data) + { + $url = 'https://api.weixin.qq.com/wxa/devplugin?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } /** * 4.获取当前所有插件使用方(供插件开发者调用) diff --git a/WeMini/Qrcode.php b/WeMini/Qrcode.php index fe31299..cacaf1f 100644 --- a/WeMini/Qrcode.php +++ b/WeMini/Qrcode.php @@ -16,7 +16,6 @@ namespace WeMini; use WeChat\Contracts\BasicWeChat; use WeChat\Contracts\Tools; -use WeChat\Exceptions\InvalidResponseException; /** * 微信小程序二维码管理 @@ -109,5 +108,5 @@ class Qrcode extends BasicWeChat } return is_null($outType) ? $result : $outType($result); } - + } \ No newline at end of file diff --git a/WeMini/Security.php b/WeMini/Security.php new file mode 100644 index 0000000..5b1901f --- /dev/null +++ b/WeMini/Security.php @@ -0,0 +1,70 @@ +registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, ['media' => $media], true); + } + + /** + * 异步校验图片/音频是否含有违法违规内容 + * @param string $media_url + * @param string $media_type + * @return array + * @throws InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function mediaCheckAsync($media_url, $media_type) + { + $url = 'https://api.weixin.qq.com/wxa/media_check_async?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, ['media_url' => $media_url, 'media_type' => $media_type], true); + } + + /** + * 检查一段文本是否含有违法违规内容 + * @param string $content + * @return array + * @throws InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function msgSecCheck($content) + { + $url = 'https://api.weixin.qq.com/wxa/msg_sec_check?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, ['content' => $content], true); + } +} \ No newline at end of file diff --git a/WeMini/Soter.php b/WeMini/Soter.php new file mode 100644 index 0000000..7890568 --- /dev/null +++ b/WeMini/Soter.php @@ -0,0 +1,40 @@ +registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + +} \ No newline at end of file diff --git a/WeMini/Template.php b/WeMini/Template.php index 516d407..730f8c3 100644 --- a/WeMini/Template.php +++ b/WeMini/Template.php @@ -107,4 +107,20 @@ class Template extends BasicWeChat return $this->callPostApi($url, $data, true); } + /** + * 下发小程序和公众号统一的服务消息 + * @param array $data + * @return array + * @throws \WeChat\Exceptions\InvalidResponseException + * @throws \WeChat\Exceptions\LocalCacheException + */ + public function uniformSend($data) + { + $url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=ACCESS_TOKEN'; + $this->registerApi($url, __FUNCTION__, func_get_args()); + return $this->callPostApi($url, $data, true); + } + + + } \ No newline at end of file