diff --git a/WeChat/Card.php b/WeChat/Card.php index c2e6ff3..436024b 100644 --- a/WeChat/Card.php +++ b/WeChat/Card.php @@ -35,38 +35,35 @@ class Card extends BasicWeChat public function create(array $data) { $url = "https://api.weixin.qq.com/card/create?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** * 设置买单接口 - * @param string $card_id - * @param bool $is_open + * @param string $cardId + * @param bool $isOpen * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function setPaycell($card_id, $is_open = true) + public function setPaycell($cardId, $isOpen = true) { $url = "https://api.weixin.qq.com/card/paycell/set?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['card_id' => $card_id, 'is_open' => $is_open]); + return $this->callPostApi($url, ['card_id' => $cardId, 'is_open' => $isOpen]); } /** * 设置自助核销接口 - * @param string $card_id - * @param bool $is_open + * @param string $cardId + * @param bool $isOpen * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function setConsumeCell($card_id, $is_open = true) + public function setConsumeCell($cardId, $isOpen = true) { $url = "https://api.weixin.qq.com/card/selfconsumecell/set?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['card_id' => $card_id, 'is_open' => $is_open]); + return $this->callPostApi($url, ['card_id' => $cardId, 'is_open' => $isOpen]); } /** @@ -79,8 +76,7 @@ class Card extends BasicWeChat public function createQrc(array $data) { $url = "https://api.weixin.qq.com/card/qrcode/create?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -93,66 +89,61 @@ class Card extends BasicWeChat public function createLandingPage(array $data) { $url = "https://api.weixin.qq.com/card/landingpage/create?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** * 导入自定义code - * @param string $card_id + * @param string $cardId * @param array $code * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function deposit($card_id, array $code) + public function deposit($cardId, array $code) { $url = "https://api.weixin.qq.com/card/code/deposit?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['card_id' => $card_id, 'code' => $code]); + return $this->callPostApi($url, ['card_id' => $cardId, 'code' => $code]); } /** * 查询导入code数目 - * @param string $card_id + * @param string $cardId * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function getDepositCount($card_id) + public function getDepositCount($cardId) { $url = "https://api.weixin.qq.com/card/code/getdepositcount?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['card_id' => $card_id]); + return $this->callPostApi($url, ['card_id' => $cardId]); } /** * 核查code接口 - * @param string $card_id 进行导入code的卡券ID + * @param string $cardId 进行导入code的卡券ID * @param array $code 已经微信卡券后台的自定义code,上限为100个 * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function checkCode($card_id, array $code) + public function checkCode($cardId, array $code) { $url = "https://api.weixin.qq.com/card/code/checkcode?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['card_id' => $card_id, 'code' => $code]); + return $this->callPostApi($url, ['card_id' => $cardId, 'code' => $code]); } /** * 图文消息群发卡券 - * @param string $card_id + * @param string $cardId * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function getNewsHtml($card_id) + public function getNewsHtml($cardId) { $url = "https://api.weixin.qq.com/card/mpnews/gethtml?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['card_id' => $card_id]); + return $this->callPostApi($url, ['card_id' => $cardId]); } /** @@ -166,27 +157,25 @@ class Card extends BasicWeChat public function setTestWhiteList($openids = [], $usernames = []) { $url = "https://api.weixin.qq.com/card/testwhitelist/set?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['openid' => $openids, 'username' => $usernames]); + return $this->callPostApi($url, ['openid' => $openids, 'username' => $usernames]); } /** * 线下核销查询Code * @param string $code 单张卡券的唯一标准 - * @param string $card_id 卡券ID代表一类卡券。自定义code卡券必填 - * @param bool $check_consume 是否校验code核销状态,填入true和false时的code异常状态返回数据不同 + * @param string $cardId 卡券ID代表一类卡券。自定义code卡券必填 + * @param bool $checkConsume 是否校验code核销状态,填入true和false时的code异常状态返回数据不同 * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function getCode($code, $card_id = null, $check_consume = null) + public function getCode($code, $cardId = null, $checkConsume = null) { $data = ['code' => $code]; - is_null($card_id) || $data['card_id'] = $card_id; - is_null($check_consume) || $data['check_consume'] = $check_consume; + is_null($cardId) || $data['card_id'] = $cardId; + is_null($checkConsume) || $data['check_consume'] = $checkConsume; $url = "https://api.weixin.qq.com/card/code/get?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -202,86 +191,80 @@ class Card extends BasicWeChat $data = ['code' => $code]; is_null($card_id) || $data['card_id'] = $card_id; $url = "https://api.weixin.qq.com/card/code/consume?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** * Code解码接口 - * @param string $encrypt_code + * @param string $encryptCode * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function decrypt($encrypt_code) + public function decrypt($encryptCode) { $url = "https://api.weixin.qq.com/card/code/decrypt?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['encrypt_code' => $encrypt_code]); + return $this->callPostApi($url, ['encrypt_code' => $encryptCode]); } /** * 获取用户已领取卡券接口 * @param string $openid - * @param null|string $card_id + * @param null|string $cardId * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function getCardList($openid, $card_id = null) + public function getCardList($openid, $cardId = null) { $data = ['openid' => $openid]; - is_null($card_id) || $data['card_id'] = $card_id; + is_null($cardId) || $data['card_id'] = $cardId; $url = "https://api.weixin.qq.com/card/user/getcardlist?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** * 查看卡券详情 - * @param string $card_id + * @param string $cardId * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function getCard($card_id) + public function getCard($cardId) { $url = "https://api.weixin.qq.com/card/get?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['card_id' => $card_id]); + return $this->callPostApi($url, ['card_id' => $cardId]); } /** * 批量查询卡券列表 * @param int $offset 查询卡列表的起始偏移量,从0开始,即offset: 5是指从从列表里的第六个开始读取 * @param int $count 需要查询的卡片的数量(数量最大50) - * @param array $status_list 支持开发者拉出指定状态的卡券列表 + * @param array $statusList 支持开发者拉出指定状态的卡券列表 * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function batchGet($offset, $count = 50, array $status_list = []) + public function batchGet($offset, $count = 50, array $statusList = []) { $data = ['offset' => $offset, 'count' => $count]; - empty($status_list) || $data['status_list'] = $status_list; + empty($statusList) || $data['status_list'] = $statusList; $url = "https://api.weixin.qq.com/card/batchget?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** * 更改卡券信息接口 - * @param string $card_id - * @param array $member_card + * @param string $cardId + * @param array $memberCard * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function updateCard($card_id, array $member_card) + public function updateCard($cardId, array $memberCard) { $url = "https://api.weixin.qq.com/card/update?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['card_id' => $card_id, 'member_card' => $member_card]); + return $this->callPostApi($url, ['card_id' => $cardId, 'member_card' => $memberCard]); } /** @@ -296,11 +279,10 @@ class Card extends BasicWeChat public function modifyStock($card_id, $increase_stock_value = null, $reduce_stock_value = null) { $data = ['card_id' => $card_id]; - is_null($increase_stock_value) || $data['increase_stock_value'] = $increase_stock_value; is_null($reduce_stock_value) || $data['reduce_stock_value'] = $reduce_stock_value; + is_null($increase_stock_value) || $data['increase_stock_value'] = $increase_stock_value; $url = "https://api.weixin.qq.com/card/modifystock?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -317,76 +299,71 @@ class Card extends BasicWeChat $data = ['code' => $code, 'new_code' => $new_code]; is_null($card_id) || $data['card_id'] = $card_id; $url = "https://api.weixin.qq.com/card/code/update?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** * 删除卡券接口 - * @param string $card_id + * @param string $cardId * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function deleteCard($card_id) + public function deleteCard($cardId) { $url = "https://api.weixin.qq.com/card/delete?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['card_id' => $card_id]); + return $this->callPostApi($url, ['card_id' => $cardId]); } /** * 设置卡券失效接口 * @param string $code - * @param string $card_id + * @param string $cardId * @param null|string $reason * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function unAvailable($code, $card_id, $reason = null) + public function unAvailable($code, $cardId, $reason = null) { - $data = ['code' => $code, 'card_id' => $card_id]; + $data = ['code' => $code, 'card_id' => $cardId]; is_null($reason) || $data['reason'] = $reason; $url = "https://api.weixin.qq.com/card/code/unavailable?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** * 拉取卡券概况数据接口 - * @param string $begin_date 查询数据的起始时间 - * @param string $end_date 查询数据的截至时间 - * @param string $cond_source 卡券来源(0为公众平台创建的卡券数据 1是API创建的卡券数据) + * @param string $beginDate 查询数据的起始时间 + * @param string $endDate 查询数据的截至时间 + * @param string $condSource 卡券来源(0为公众平台创建的卡券数据 1是API创建的卡券数据) * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function getCardBizuininfo($begin_date, $end_date, $cond_source) + public function getCardBizuininfo($beginDate, $endDate, $condSource) { - $data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'cond_source' => $cond_source]; $url = "https://api.weixin.qq.com/datacube/getcardbizuininfo?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + $data = ['begin_date' => $beginDate, 'end_date' => $endDate, 'cond_source' => $condSource]; + return $this->callPostApi($url, $data); } /** * 获取免费券数据接口 - * @param string $begin_date 查询数据的起始时间 - * @param string $end_date 查询数据的截至时间 - * @param integer $cond_source 卡券来源,0为公众平台创建的卡券数据、1是API创建的卡券数据 - * @param null $card_id 卡券ID + * @param string $beginDate 查询数据的起始时间 + * @param string $endDate 查询数据的截至时间 + * @param integer $condSource 卡券来源,0为公众平台创建的卡券数据、1是API创建的卡券数据 + * @param null $cardId 卡券ID * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function getCardCardinfo($begin_date, $end_date, $cond_source, $card_id = null) + public function getCardCardinfo($beginDate, $endDate, $condSource, $cardId = null) { - $data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'cond_source' => $cond_source]; - is_null($card_id) || $data['card_id'] = $card_id; $url = "https://api.weixin.qq.com/datacube/getcardcardinfo?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + $data = ['begin_date' => $beginDate, 'end_date' => $endDate, 'cond_source' => $condSource]; + is_null($cardId) || $data['card_id'] = $cardId; + return $this->callPostApi($url, $data); } @@ -400,8 +377,7 @@ class Card extends BasicWeChat public function activateMemberCard(array $data) { $url = 'https://api.weixin.qq.com/card/membercard/activate?access_token=ACCESS_TOKEN'; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -415,23 +391,21 @@ class Card extends BasicWeChat public function setActivateMemberCardUser(array $data) { $url = 'https://api.weixin.qq.com/card/membercard/activateuserform/set?access_token=ACCESS_TOKEN'; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** * 获取用户提交资料 * 根据activate_ticket获取到用户填写的信息 - * @param string $activate_ticket + * @param string $activateTicket * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function getActivateMemberCardTempinfo($activate_ticket) + public function getActivateMemberCardTempinfo($activateTicket) { $url = 'https://api.weixin.qq.com/card/membercard/activatetempinfo/get?access_token=ACCESS_TOKEN'; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['activate_ticket' => $activate_ticket]); + return $this->callPostApi($url, ['activate_ticket' => $activateTicket]); } /** @@ -444,58 +418,54 @@ class Card extends BasicWeChat public function updateMemberCardUser(array $data) { $url = 'https://api.weixin.qq.com/card/membercard/updateuser?access_token=ACCESS_TOKEN'; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** * 拉取会员卡概况数据接口 - * @param string $begin_date 查询数据的起始时间 - * @param string $end_date 查询数据的截至时间 - * @param string $cond_source 卡券来源(0为公众平台创建的卡券数据 1是API创建的卡券数据) + * @param string $beginDate 查询数据的起始时间 + * @param string $endDate 查询数据的截至时间 + * @param string $condSource 卡券来源(0为公众平台创建的卡券数据 1是API创建的卡券数据) * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function getCardMemberCardinfo($begin_date, $end_date, $cond_source) + public function getCardMemberCardinfo($beginDate, $endDate, $condSource) { - $data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'cond_source' => $cond_source]; $url = "https://api.weixin.qq.com/datacube/getcardmembercardinfo?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + $data = ['begin_date' => $beginDate, 'end_date' => $endDate, 'cond_source' => $condSource]; + return $this->callPostApi($url, $data); } /** * 拉取单张会员卡数据接口 - * @param string $begin_date 查询数据的起始时间 - * @param string $end_date 查询数据的截至时间 - * @param string $card_id 卡券id + * @param string $beginDate 查询数据的起始时间 + * @param string $endDate 查询数据的截至时间 + * @param string $cardId 卡券id * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function getCardMemberCardDetail($begin_date, $end_date, $card_id) + public function getCardMemberCardDetail($beginDate, $endDate, $cardId) { - $data = ['begin_date' => $begin_date, 'end_date' => $end_date, 'card_id' => $card_id]; $url = "https://api.weixin.qq.com/datacube/getcardmembercarddetail?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + $data = ['begin_date' => $beginDate, 'end_date' => $endDate, 'card_id' => $cardId]; + return $this->callPostApi($url, $data); } /** * 拉取会员信息(积分查询)接口 - * @param string $card_id 查询会员卡的cardid + * @param string $cardId 查询会员卡的cardid * @param string $code 所查询用户领取到的code值 * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function getCardMemberCard($card_id, $code) + public function getCardMemberCard($cardId, $code) { - $data = ['card_id' => $card_id, 'code' => $code]; + $data = ['card_id' => $cardId, 'code' => $code]; $url = "https://api.weixin.qq.com/card/membercard/userinfo/get?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -508,36 +478,33 @@ class Card extends BasicWeChat public function payGiftCard(array $data) { $url = "https://api.weixin.qq.com/card/paygiftcard/add?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** * 删除支付后投放卡券规则 - * @param integer $rule_id 支付即会员的规则名称 + * @param integer $ruleId 支付即会员的规则名称 * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function delPayGiftCard($rule_id) + public function delPayGiftCard($ruleId) { $url = "https://api.weixin.qq.com/card/paygiftcard/add?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['rule_id' => $rule_id]); + return $this->callPostApi($url, ['rule_id' => $ruleId]); } /** * 查询支付后投放卡券规则详情 - * @param integer $rule_id 要查询规则id + * @param integer $ruleId 要查询规则id * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function getPayGiftCard($rule_id) + public function getPayGiftCard($ruleId) { $url = "https://api.weixin.qq.com/card/paygiftcard/getbyid?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['rule_id' => $rule_id]); + return $this->callPostApi($url, ['rule_id' => $ruleId]); } /** @@ -551,10 +518,9 @@ class Card extends BasicWeChat */ public function batchGetPayGiftCard($offset = 0, $count = 10, $effective = true) { - $data = ['type' => 'RULE_TYPE_PAY_MEMBER_CARD', 'offset' => $offset, 'count' => $count, 'effective' => $effective]; $url = "https://api.weixin.qq.com/card/paygiftcard/batchget?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + $data = ['type' => 'RULE_TYPE_PAY_MEMBER_CARD', 'offset' => $offset, 'count' => $count, 'effective' => $effective]; + return $this->callPostApi($url, $data); } /** @@ -567,8 +533,7 @@ class Card extends BasicWeChat public function addActivity(array $data) { $url = "https://api.weixin.qq.com/card/mkt/activity/create?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -580,23 +545,21 @@ class Card extends BasicWeChat public function payActivate() { $url = "https://api.weixin.qq.com/card/pay/activate?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpGetForJson($url); + return $this->callGetApi($url); } /** * 对优惠券批价 - * @param string $card_id 需要来配置库存的card_id + * @param string $cardId 需要来配置库存的card_id * @param integer $quantity 本次需要兑换的库存数目 * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function getPayprice($card_id, $quantity) + public function getPayprice($cardId, $quantity) { $url = "POST https://api.weixin.qq.com/card/pay/getpayprice?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['card_id' => $card_id, 'quantity' => $quantity]); + return $this->callPostApi($url, ['card_id' => $cardId, 'quantity' => $quantity]); } /** @@ -608,53 +571,49 @@ class Card extends BasicWeChat public function getCoinsInfo() { $url = "https://api.weixin.qq.com/card/pay/getcoinsinfo?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpGetForJson($url); + return $this->callGetApi($url); } /** * 确认兑换库存接口 - * @param string $card_id 需要来兑换库存的card_id + * @param string $cardId 需要来兑换库存的card_id * @param integer $quantity 本次需要兑换的库存数目 - * @param string $order_id 仅可以使用上面得到的订单号,保证批价有效性 + * @param string $orderId 仅可以使用上面得到的订单号,保证批价有效性 * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function payConfirm($card_id, $quantity, $order_id) + public function payConfirm($cardId, $quantity, $orderId) { - $data = ['card_id' => $card_id, 'quantity' => $quantity, 'order_id' => $order_id]; $url = "https://api.weixin.qq.com/card/pay/confirm?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + $data = ['card_id' => $cardId, 'quantity' => $quantity, 'order_id' => $orderId]; + return $this->callPostApi($url, $data); } /** * 充值券点接口 - * @param integer $coin_count + * @param integer $coinCount * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function payRecharge($coin_count) + public function payRecharge($coinCount) { $url = "https://api.weixin.qq.com/card/pay/recharge?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['coin_count' => $coin_count]); + return $this->callPostApi($url, ['coin_count' => $coinCount]); } /** * 查询订单详情接口 - * @param string $order_id + * @param string $orderId * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function payGetOrder($order_id) + public function payGetOrder($orderId) { $url = "https://api.weixin.qq.com/card/pay/getorder?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['order_id' => $order_id]); + return $this->callPostApi($url, ['order_id' => $orderId]); } /** @@ -667,8 +626,6 @@ class Card extends BasicWeChat public function payGetList(array $data) { $url = "https://api.weixin.qq.com/card/pay/getorderlist?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } - } \ No newline at end of file diff --git a/WeChat/Custom.php b/WeChat/Custom.php index c21ba31..bfca666 100644 --- a/WeChat/Custom.php +++ b/WeChat/Custom.php @@ -36,55 +36,49 @@ class Custom extends BasicWeChat */ public function addAccount($kf_account, $nickname) { - $data = ['kf_account' => $kf_account, 'nickname' => $nickname]; $url = "https://api.weixin.qq.com/customservice/kfaccount/add?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, ['kf_account' => $kf_account, 'nickname' => $nickname]); } /** * 修改客服帐号 - * @param string $kf_account 客服账号 + * @param string $kfAccount 客服账号 * @param string $nickname 客服昵称 * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function updateAccount($kf_account, $nickname) + public function updateAccount($kfAccount, $nickname) { - $data = ['kf_account' => $kf_account, 'nickname' => $nickname]; $url = "https://api.weixin.qq.com/customservice/kfaccount/update?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, ['kf_account' => $kfAccount, 'nickname' => $nickname]); } /** * 删除客服帐号 - * @param string $kf_account 客服账号 + * @param string $kfAccount 客服账号 * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function deleteAccount($kf_account) + public function deleteAccount($kfAccount) { - $data = ['kf_account' => $kf_account]; $url = "https://api.weixin.qq.com/customservice/kfaccount/del?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, ['kf_account' => $kfAccount]); } /** * 邀请绑定客服帐号 - * @param string $kf_account 完整客服帐号,格式为:帐号前缀@公众号微信号 + * @param string $kfAccount 完整客服帐号,格式为:帐号前缀@公众号微信号 * @param string $invite_wx 接收绑定邀请的客服微信号 * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function inviteWorker($kf_account, $invite_wx) + public function inviteWorker($kfAccount, $invite_wx) { $url = 'https://api.weixin.qq.com/customservice/kfaccount/inviteworker?access_token=ACCESS_TOKEN'; - return $this->callPostApi($url, ['kf_account' => $kf_account, 'invite_wx' => $invite_wx]); + return $this->callPostApi($url, ['kf_account' => $kfAccount, 'invite_wx' => $invite_wx]); } /** @@ -96,8 +90,7 @@ class Custom extends BasicWeChat public function getAccountList() { $url = "https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpGetForJson($url); + return $this->callGetApi($url); } /** @@ -110,9 +103,8 @@ class Custom extends BasicWeChat */ public function uploadHeadimg($kf_account, $image) { - $url = "http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=ACCESS_TOKEN&kf_account={$kf_account}"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['media' => Tools::createCurlFile($image)]); + $url = "https://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=ACCESS_TOKEN&kf_account={$kf_account}"; + return $this->callPostApi($url, ['media' => Tools::createCurlFile($image)], false); } /** @@ -125,8 +117,7 @@ class Custom extends BasicWeChat public function send(array $data) { $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -140,8 +131,7 @@ class Custom extends BasicWeChat public function typing($openid, $command = 'Typing') { $url = "https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['touser' => $openid, 'command' => $command]); + return $this->callPostApi($url, ['touser' => $openid, 'command' => $command]); } /** @@ -154,8 +144,7 @@ class Custom extends BasicWeChat public function massSendAll(array $data) { $url = "https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -168,8 +157,7 @@ class Custom extends BasicWeChat public function massSend(array $data) { $url = "https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -185,8 +173,7 @@ class Custom extends BasicWeChat $data = ['msg_id' => $msg_id]; is_null($article_idx) || $data['article_idx'] = $article_idx; $url = "https://api.weixin.qq.com/cgi-bin/message/mass/delete?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -199,22 +186,20 @@ class Custom extends BasicWeChat public function massPreview(array $data) { $url = "https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** * 查询群发消息发送状态【订阅号与服务号认证后均可用】 - * @param integer $msg_id 群发消息后返回的消息id + * @param integer $msgId 群发消息后返回的消息id * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function massGet($msg_id) + public function massGet($msgId) { $url = "https://api.weixin.qq.com/cgi-bin/message/mass/get?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['msg_id' => $msg_id]); + return $this->callPostApi($url, ['msg_id' => $msgId]); } /** @@ -226,8 +211,7 @@ class Custom extends BasicWeChat public function massGetSeed() { $url = "https://api.weixin.qq.com/cgi-bin/message/mass/speed/get?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, []); + return $this->callPostApi($url, []); } /** @@ -240,9 +224,6 @@ class Custom extends BasicWeChat public function massSetSeed($speed) { $url = "https://api.weixin.qq.com/cgi-bin/message/mass/speed/set?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['speed' => $speed]); + return $this->callPostApi($url, ['speed' => $speed]); } - - } \ No newline at end of file diff --git a/WeChat/Draft.php b/WeChat/Draft.php index 9fcc061..0a097af 100644 --- a/WeChat/Draft.php +++ b/WeChat/Draft.php @@ -36,38 +36,34 @@ class Draft extends BasicWeChat public function add($articles) { $url = "https://api.weixin.qq.com/cgi-bin/draft/add?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['articles' => $articles]); + return $this->callPostApi($url, ['articles' => $articles]); } /** * 获取草稿 - * @param string $media_id + * @param string $mediaId * @param string $outType 返回处理函数 * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function get($media_id, $outType = null) + public function get($mediaId, $outType = null) { $url = "https://api.weixin.qq.com/cgi-bin/draft/get?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['media_id' => $media_id]); + return $this->callPostApi($url, ['media_id' => $mediaId]); } - /** * 删除草稿 - * @param string $media_id + * @param string $mediaId * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function delete($media_id) + public function delete($mediaId) { $url = "https://api.weixin.qq.com/cgi-bin/draft/delete?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['media_id' => $media_id]); + return $this->callPostApi($url, ['media_id' => $mediaId]); } /** @@ -80,8 +76,7 @@ class Draft extends BasicWeChat public function addNews($data) { $url = "https://api.weixin.qq.com/cgi-bin/material/add_news?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -95,10 +90,9 @@ class Draft extends BasicWeChat */ public function update($media_id, $index, $articles) { - $data = ['media_id' => $media_id, 'index' => $index, 'articles' => $articles]; $url = "https://api.weixin.qq.com/cgi-bin/draft/update?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + $data = ['media_id' => $media_id, 'index' => $index, 'articles' => $articles]; + return $this->callPostApi($url, $data); } /** @@ -110,24 +104,21 @@ class Draft extends BasicWeChat public function getCount() { $url = "https://api.weixin.qq.com/cgi-bin/draft/count?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpGetForJson($url); + return $this->callGetApi($url); } /** * 获取草稿列表 * @param int $offset 从全部素材的该偏移位置开始返回,0表示从第一个素材返回 * @param int $count 返回素材的数量,取值在1到20之间 - * @param int $no_content 1 表示不返回 content 字段,0 表示正常返回,默认为 0 + * @param int $noContent 1 表示不返回 content 字段,0 表示正常返回,默认为 0 * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function batchGet($offset = 0, $count = 20, $no_content = 0) + public function batchGet($offset = 0, $count = 20, $noContent = 0) { $url = "https://api.weixin.qq.com/cgi-bin/draft/batchget?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['no_content' => $no_content, 'offset' => $offset, 'count' => $count]); + return $this->callPostApi($url, ['no_content' => $noContent, 'offset' => $offset, 'count' => $count]); } - } diff --git a/WeChat/Freepublish.php b/WeChat/Freepublish.php index 84f57ad..1cd9614 100644 --- a/WeChat/Freepublish.php +++ b/WeChat/Freepublish.php @@ -29,75 +29,70 @@ class Freepublish extends BasicWeChat /** * 发布接口 * 开发者需要先将图文素材以草稿的形式保存(见“草稿箱/新建草稿”,如需从已保存的草稿中选择,见“草稿箱/获取草稿列表”) - * @param mixed $media_id 选择要发布的草稿的media_id + * @param mixed $mediaId 选择要发布的草稿的media_id * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function submit($media_id) + public function submit($mediaId) { $url = "https://api.weixin.qq.com/cgi-bin/freepublish/submit?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['media_id' => $media_id]); + return $this->callPostApi($url, ['media_id' => $mediaId]); } /** * 发布状态轮询接口 - * @param mixed $publish_id + * @param mixed $publishId * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function get($publish_id) + public function get($publishId) { $url = "https://api.weixin.qq.com/cgi-bin/freepublish/get?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['publish_id' => $publish_id]); + return $this->callPostApi($url, ['publish_id' => $publishId]); } /** * 删除发布 * 发布成功之后,随时可以通过该接口删除。此操作不可逆,请谨慎操作。 - * @param mixed $article_id 成功发布时返回的 article_id + * @param mixed $articleId 成功发布时返回的 article_id * @param int $index 要删除的文章在图文消息中的位置,第一篇编号为1,该字段不填或填0会删除全部文章 * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function delete($article_id, $index = 0) + public function delete($articleId, $index = 0) { $url = "https://api.weixin.qq.com/cgi-bin/freepublish/delete?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['article_id' => $article_id, 'index' => $index]); + return $this->callPostApi($url, ['article_id' => $articleId, 'index' => $index]); } /** * 通过 article_id 获取已发布文章 - * @param mixed $article_id 要获取的草稿的article_id + * @param mixed $articleId 要获取的草稿的article_id * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function getArticle($article_id) + public function getArticle($articleId) { $url = "https://api.weixin.qq.com/cgi-bin/freepublish/getarticle?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['article_id' => $article_id]); + return $this->callPostApi($url, ['article_id' => $articleId]); } /** * 获取成功发布列表 * @param int $offset 从全部素材的该偏移位置开始返回,0表示从第一个素材返回 * @param int $count 返回素材的数量,取值在1到20之间 - * @param int $no_content 1 表示不返回 content 字段,0 表示正常返回,默认为 0 + * @param int $noContent 1 表示不返回 content 字段,0 表示正常返回,默认为 0 * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function batchGet($offset = 0, $count = 20, $no_content = 0) + public function batchGet($offset = 0, $count = 20, $noContent = 0) { $url = "https://api.weixin.qq.com/cgi-bin/freepublish/batchget?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['no_content' => $no_content, 'offset' => $offset, 'count' => $count]); + return $this->callPostApi($url, ['no_content' => $noContent, 'offset' => $offset, 'count' => $count]); } } \ No newline at end of file diff --git a/WeChat/Limit.php b/WeChat/Limit.php index 785e9c3..05973c9 100644 --- a/WeChat/Limit.php +++ b/WeChat/Limit.php @@ -61,7 +61,6 @@ class Limit extends BasicWeChat public function getCallbackIp() { $url = 'https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=ACCESS_TOKEN'; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpGetForJson($url); + return $this->callGetApi($url); } } \ No newline at end of file diff --git a/WeChat/Media.php b/WeChat/Media.php index 1121a45..22feec2 100644 --- a/WeChat/Media.php +++ b/WeChat/Media.php @@ -41,8 +41,7 @@ class Media extends BasicWeChat throw new InvalidResponseException('Invalid Media Type.', '0'); } $url = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type={$type}"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['media' => Tools::createCurlFile($filename)], false); + return $this->callPostApi($url, ['media' => Tools::createCurlFile($filename)], false); } /** @@ -57,7 +56,7 @@ class Media extends BasicWeChat { $url = "https://api.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id={$media_id}"; $this->registerApi($url, __FUNCTION__, func_get_args()); - if($outType=='url') return $url; + if ($outType == 'url') return $url; $result = Tools::get($url); if (is_array($json = json_decode($result, true))) { if (!$this->isTry && isset($json['errcode']) && in_array($json['errcode'], ['40014', '40001', '41001', '42001'])) { @@ -79,8 +78,7 @@ class Media extends BasicWeChat public function addNews($data) { $url = "https://api.weixin.qq.com/cgi-bin/material/add_news?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -94,10 +92,8 @@ class Media extends BasicWeChat */ public function updateNews($media_id, $index, $news) { - $data = ['media_id' => $media_id, 'index' => $index, 'articles' => $news]; $url = "https://api.weixin.qq.com/cgi-bin/material/update_news?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, ['media_id' => $media_id, 'index' => $index, 'articles' => $news]); } /** @@ -110,8 +106,7 @@ class Media extends BasicWeChat public function uploadImg($filename) { $url = "https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['media' => Tools::createCurlFile($filename)], false); + return $this->callPostApi($url, ['media' => Tools::createCurlFile($filename)], false); } /** @@ -129,8 +124,7 @@ class Media extends BasicWeChat throw new InvalidResponseException('Invalid Media Type.', '0'); } $url = "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type={$type}"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['media' => Tools::createCurlFile($filename), 'description' => Tools::arr2json($description)], false); + return $this->callPostApi($url, ['media' => Tools::createCurlFile($filename), 'description' => Tools::arr2json($description)], false); } /** @@ -145,7 +139,7 @@ class Media extends BasicWeChat { $url = "https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=ACCESS_TOKEN"; $this->registerApi($url, __FUNCTION__, func_get_args()); - if($outType=='url') return $url; + if ($outType == 'url') return $url; $result = Tools::post($url, ['media_id' => $media_id]); if (is_array($json = json_decode($result, true))) { if (!$this->isTry && isset($json['errcode']) && in_array($json['errcode'], ['40014', '40001', '41001', '42001'])) { @@ -159,16 +153,15 @@ class Media extends BasicWeChat /** * 删除永久素材 - * @param string $media_id + * @param string $mediaId * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function delMaterial($media_id) + public function delMaterial($mediaId) { $url = "https://api.weixin.qq.com/cgi-bin/material/del_material?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['media_id' => $media_id]); + return $this->httpPostForJson($url, ['media_id' => $mediaId]); } /** @@ -180,8 +173,7 @@ class Media extends BasicWeChat public function getMaterialCount() { $url = "https://api.weixin.qq.com/cgi-bin/material/get_materialcount?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpGetForJson($url); + return $this->callGetApi($url); } /** @@ -199,7 +191,6 @@ class Media extends BasicWeChat throw new InvalidResponseException('Invalid Media Type.', '0'); } $url = "https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['type' => $type, 'offset' => $offset, 'count' => $count]); + return $this->callPostApi($url, ['type' => $type, 'offset' => $offset, 'count' => $count]); } } \ No newline at end of file diff --git a/WeChat/Menu.php b/WeChat/Menu.php index ac67886..4f31c77 100644 --- a/WeChat/Menu.php +++ b/WeChat/Menu.php @@ -35,8 +35,7 @@ class Menu extends BasicWeChat public function get() { $url = "https://api.weixin.qq.com/cgi-bin/menu/get?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpGetForJson($url); + return $this->callGetApi($url); } /** @@ -48,8 +47,7 @@ class Menu extends BasicWeChat public function delete() { $url = "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpGetForJson($url); + return $this->callGetApi($url); } /** @@ -62,8 +60,7 @@ class Menu extends BasicWeChat public function create(array $data) { $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -76,8 +73,7 @@ class Menu extends BasicWeChat public function addConditional(array $data) { $url = "https://api.weixin.qq.com/cgi-bin/menu/addconditional?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -90,8 +86,7 @@ class Menu extends BasicWeChat public function delConditional($menuid) { $url = "https://api.weixin.qq.com/cgi-bin/menu/delconditional?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['menuid' => $menuid]); + return $this->callPostApi($url, ['menuid' => $menuid]); } /** @@ -104,7 +99,6 @@ class Menu extends BasicWeChat public function tryConditional($openid) { $url = "https://api.weixin.qq.com/cgi-bin/menu/trymatch?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['user_id' => $openid]); + return $this->callPostApi($url, ['user_id' => $openid]); } } \ No newline at end of file diff --git a/WeChat/Oauth.php b/WeChat/Oauth.php index 62c0c04..0dd5b13 100644 --- a/WeChat/Oauth.php +++ b/WeChat/Oauth.php @@ -72,30 +72,30 @@ class Oauth extends BasicWeChat /** * 检验授权凭证(access_token)是否有效 - * @param string $access_token 网页授权接口调用凭证,注意:此access_token与基础支持的access_token不同 + * @param string $accessToken 网页授权接口调用凭证,注意:此access_token与基础支持的access_token不同 * @param string $openid 用户的唯一标识 * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function checkOauthAccessToken($access_token, $openid) + public function checkOauthAccessToken($accessToken, $openid) { - $url = "https://api.weixin.qq.com/sns/auth?access_token={$access_token}&openid={$openid}"; + $url = "https://api.weixin.qq.com/sns/auth?access_token={$accessToken}&openid={$openid}"; return $this->httpGetForJson($url); } /** * 拉取用户信息(需scope为 snsapi_userinfo) - * @param string $access_token 网页授权接口调用凭证,注意:此access_token与基础支持的access_token不同 + * @param string $accessToken 网页授权接口调用凭证,注意:此access_token与基础支持的access_token不同 * @param string $openid 用户的唯一标识 * @param string $lang 返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语 * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function getUserInfo($access_token, $openid, $lang = 'zh_CN') + public function getUserInfo($accessToken, $openid, $lang = 'zh_CN') { - $url = "https://api.weixin.qq.com/sns/userinfo?access_token={$access_token}&openid={$openid}&lang={$lang}"; + $url = "https://api.weixin.qq.com/sns/userinfo?access_token={$accessToken}&openid={$openid}&lang={$lang}"; return $this->httpGetForJson($url); } } diff --git a/WeChat/Product.php b/WeChat/Product.php index 2fff299..7c6fc44 100644 --- a/WeChat/Product.php +++ b/WeChat/Product.php @@ -36,10 +36,9 @@ class Product extends BasicWeChat */ public function modStatus($keystandard, $keystr, $status = 'on') { - $data = ['keystandard' => $keystandard, 'keystr' => $keystr, 'status' => $status]; $url = "https://api.weixin.qq.com/scan/product/modstatus?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + $data = ['keystandard' => $keystandard, 'keystr' => $keystr, 'status' => $status]; + return $this->callPostApi($url, $data); } /** @@ -52,10 +51,8 @@ class Product extends BasicWeChat */ public function setTestWhiteList(array $openids = [], array $usernames = []) { - $data = ['openid' => $openids, 'username' => $usernames]; $url = "https://api.weixin.qq.com/scan/testwhitelist/set?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, ['openid' => $openids, 'username' => $usernames]); } /** @@ -70,11 +67,10 @@ class Product extends BasicWeChat */ public function getQrcode($keystandard, $keystr, $qrcode_size, $extinfo = []) { + $url = "https://api.weixin.qq.com/scan/product/getqrcode?access_token=ACCESS_TOKEN"; $data = ['keystandard' => $keystandard, 'keystr' => $keystr, 'qrcode_size' => $qrcode_size]; empty($extinfo) || $data['extinfo'] = $extinfo; - $url = "https://api.weixin.qq.com/scan/product/getqrcode?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -87,11 +83,10 @@ class Product extends BasicWeChat */ public function getProduct($keystandard, $keystr) { + $url = "https://api.weixin.qq.com/scan/product/get?access_token=ACCESS_TOKEN"; $data = ['keystandard' => $keystandard, 'keystr' => $keystr]; empty($extinfo) || $data['extinfo'] = $extinfo; - $url = "https://api.weixin.qq.com/scan/product/get?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -106,12 +101,11 @@ class Product extends BasicWeChat */ public function getProductList($offset, $limit = 10, $status = null, $keystr = '') { + $url = "https://api.weixin.qq.com/scan/product/get?access_token=ACCESS_TOKEN"; $data = ['offset' => $offset, 'limit' => $limit]; is_null($status) || $data['status'] = $status; empty($keystr) || $data['keystr'] = $keystr; - $url = "https://api.weixin.qq.com/scan/product/get?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -124,8 +118,7 @@ class Product extends BasicWeChat public function updateProduct(array $data) { $url = "https://api.weixin.qq.com/scan/product/update?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -139,8 +132,7 @@ class Product extends BasicWeChat public function clearProduct($keystandard, $keystr) { $url = "https://api.weixin.qq.com/scan/product/clear?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['keystandard' => $keystandard, 'keystr' => $keystr]); + return $this->callPostApi($url, ['keystandard' => $keystandard, 'keystr' => $keystr]); } /** @@ -153,8 +145,7 @@ class Product extends BasicWeChat public function scanTicketCheck($ticket) { $url = "https://api.weixin.qq.com/scan/scanticket/check?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['ticket' => $ticket]); + return $this->callPostApi($url, ['ticket' => $ticket]); } /** @@ -168,10 +159,8 @@ class Product extends BasicWeChat */ public function clearScanticket($keystandard, $keystr, $extinfo) { - $data = ['keystandard' => $keystandard, 'keystr' => $keystr, 'extinfo' => $extinfo]; $url = "https://api.weixin.qq.com/scan/scanticket/check?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + $data = ['keystandard' => $keystandard, 'keystr' => $keystr, 'extinfo' => $extinfo]; + return $this->callPostApi($url, $data); } - } \ No newline at end of file diff --git a/WeChat/Qrcode.php b/WeChat/Qrcode.php index 3c09eff..19abd49 100644 --- a/WeChat/Qrcode.php +++ b/WeChat/Qrcode.php @@ -48,8 +48,7 @@ class Qrcode extends BasicWeChat $data['action_name'] = is_integer($scene) ? 'QR_LIMIT_SCENE' : 'QR_LIMIT_STR_SCENE'; } $url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -72,7 +71,6 @@ class Qrcode extends BasicWeChat public function shortUrl($longUrl) { $url = "https://api.weixin.qq.com/cgi-bin/shorturl?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['action' => 'long2short', 'long_url' => $longUrl]); + return $this->callPostApi($url, ['action' => 'long2short', 'long_url' => $longUrl]); } } \ No newline at end of file diff --git a/WeChat/Scan.php b/WeChat/Scan.php index f532bb2..ffd2e8a 100644 --- a/WeChat/Scan.php +++ b/WeChat/Scan.php @@ -34,8 +34,7 @@ class Scan extends BasicWeChat public function getMerchantInfo() { $url = "https://api.weixin.qq.com/scan/merchantinfo/get?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpGetForJson($url); + return $this->callGetApi($url); } /** @@ -48,8 +47,7 @@ class Scan extends BasicWeChat public function addProduct(array $data) { $url = "https://api.weixin.qq.com/scan/product/create?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -63,10 +61,9 @@ class Scan extends BasicWeChat */ public function modProduct($keystandard, $keystr, $status = 'on') { - $data = ['keystandard' => $keystandard, 'keystr' => $keystr, 'status' => $status]; $url = "https://api.weixin.qq.com/scan/product/modstatus?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + $data = ['keystandard' => $keystandard, 'keystr' => $keystr, 'status' => $status]; + return $this->callPostApi($url, $data); } /** @@ -79,10 +76,8 @@ class Scan extends BasicWeChat */ public function setTestWhiteList($openids = [], $usernames = []) { - $data = ['openid' => $openids, 'username' => $usernames]; $url = "https://api.weixin.qq.com/scan/product/modstatus?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, ['openid' => $openids, 'username' => $usernames]); } /** @@ -97,11 +92,10 @@ class Scan extends BasicWeChat */ public function getQrc($keystandard, $keystr, $extinfo = null, $qrcode_size = 64) { + $url = "https://api.weixin.qq.com/scan/product/getqrcode?access_token=ACCESS_TOKEN"; $data = ['keystandard' => $keystandard, 'keystr' => $keystr, 'qrcode_size' => $qrcode_size]; is_null($extinfo) || $data['extinfo'] = $extinfo; - $url = "https://api.weixin.qq.com/scan/product/getqrcode?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -115,8 +109,7 @@ class Scan extends BasicWeChat public function getProductInfo($keystandard, $keystr) { $url = "https://api.weixin.qq.com/scan/product/get?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['keystandard' => $keystandard, 'keystr' => $keystr]); + return $this->callPostApi($url, ['keystandard' => $keystandard, 'keystr' => $keystr]); } /** @@ -131,12 +124,11 @@ class Scan extends BasicWeChat */ public function getProductList($offset = 1, $limit = 10, $status = null, $keystr = null) { + $url = "https://api.weixin.qq.com/scan/product/getlist?access_token=ACCESS_TOKEN"; $data = ['offset' => $offset, 'limit' => $limit]; is_null($status) || $data['status'] = $status; is_null($keystr) || $data['keystr'] = $keystr; - $url = "https://api.weixin.qq.com/scan/product/getlist?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -149,8 +141,7 @@ class Scan extends BasicWeChat public function updateProduct(array $data) { $url = "https://api.weixin.qq.com/scan/product/update?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -164,8 +155,7 @@ class Scan extends BasicWeChat public function clearProduct($keystandard, $keystr) { $url = "https://api.weixin.qq.com/scan/product/clear?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['keystandard' => $keystandard, 'keystr' => $keystr]); + return $this->callPostApi($url, ['keystandard' => $keystandard, 'keystr' => $keystr]); } /** @@ -178,8 +168,7 @@ class Scan extends BasicWeChat public function checkTicket($ticket) { $url = "https://api.weixin.qq.com/scan/scanticket/check?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['ticket' => $ticket]); + return $this->callPostApi($url, ['ticket' => $ticket]); } /** @@ -194,8 +183,6 @@ class Scan extends BasicWeChat public function clearScanTicket($keystandard, $keystr, $extinfo) { $url = "https://api.weixin.qq.com/scan/scanticket/check?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['keystandard' => $keystandard, 'keystr' => $keystr, 'extinfo' => $extinfo]); + return $this->callPostApi($url, ['keystandard' => $keystandard, 'keystr' => $keystr, 'extinfo' => $extinfo]); } - } \ No newline at end of file diff --git a/WeChat/Shake.php b/WeChat/Shake.php index ba1a29a..5794c3a 100644 --- a/WeChat/Shake.php +++ b/WeChat/Shake.php @@ -36,8 +36,7 @@ class Shake extends BasicWeChat public function register(array $data) { $url = "https://api.weixin.qq.com/shakearound/account/register?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -49,8 +48,7 @@ class Shake extends BasicWeChat public function auditStatus() { $url = "https://api.weixin.qq.com/shakearound/account/auditstatus?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpGetForJson($url); + return $this->callGetApi($url); } /** @@ -69,8 +67,7 @@ class Shake extends BasicWeChat is_null($poi_id) || $data['poi_id'] = $poi_id; is_null($comment) || $data['comment'] = $comment; $url = "https://api.weixin.qq.com/shakearound/device/applyid?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -83,8 +80,7 @@ class Shake extends BasicWeChat public function getApplyStatus($applyId) { $url = "https://api.weixin.qq.com/shakearound/device/applyid?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['apply_id' => $applyId]); + return $this->callPostApi($url, ['apply_id' => $applyId]); } /** @@ -97,8 +93,7 @@ class Shake extends BasicWeChat public function updateApply(array $data) { $url = "https://api.weixin.qq.com/shakearound/device/update?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -111,8 +106,7 @@ class Shake extends BasicWeChat public function bindLocation(array $data) { $url = "https://api.weixin.qq.com/shakearound/device/bindlocation?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -125,8 +119,7 @@ class Shake extends BasicWeChat public function search(array $data) { $url = "https://api.weixin.qq.com/shakearound/device/search?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -139,8 +132,7 @@ class Shake extends BasicWeChat public function createPage(array $data) { $url = "https://api.weixin.qq.com/shakearound/page/add?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -153,8 +145,7 @@ class Shake extends BasicWeChat public function updatePage(array $data) { $url = "https://api.weixin.qq.com/shakearound/page/update?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -167,22 +158,20 @@ class Shake extends BasicWeChat public function searchPage(array $data) { $url = "https://api.weixin.qq.com/shakearound/page/search?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** * 删除页面 - * @param integer $page_id 指定页面的id + * @param integer $pageId 指定页面的id * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function deletePage($page_id) + public function deletePage($pageId) { $url = "https://api.weixin.qq.com/shakearound/page/delete?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['page_id' => $page_id]); + return $this->callPostApi($url, ['page_id' => $pageId]); } /** @@ -196,8 +185,7 @@ class Shake extends BasicWeChat public function upload($filename, $type = 'icon') { $url = "https://api.weixin.qq.com/shakearound/material/add?access_token=ACCESS_TOKEN&type={$type}"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['media' => Tools::createCurlFile($filename)]); + return $this->callPostApi($url, ['media' => Tools::createCurlFile($filename)], false); } /** @@ -210,8 +198,7 @@ class Shake extends BasicWeChat public function bindPage(array $data) { $url = "https://api.weixin.qq.com/shakearound/device/bindpage?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -224,8 +211,7 @@ class Shake extends BasicWeChat public function queryPage(array $data) { $url = "https://api.weixin.qq.com/shakearound/relation/search?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -238,68 +224,63 @@ class Shake extends BasicWeChat public function totalDevice(array $data) { $url = "https://api.weixin.qq.com/shakearound/statistics/device?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** * 批量查询设备统计数据接口 * @param integer $date 指定查询日期时间戳,单位为秒 - * @param integer $page_index 指定查询的结果页序号;返回结果按摇周边人数降序排序,每50条记录为一页 + * @param integer $pageIndex 指定查询的结果页序号;返回结果按摇周边人数降序排序,每50条记录为一页 * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function totalDeviceList($date, $page_index = 1) + public function totalDeviceList($date, $pageIndex = 1) { $url = "https://api.weixin.qq.com/shakearound/statistics/devicelist?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['date' => $date, 'page_index' => $page_index]); + return $this->callPostApi($url, ['date' => $date, 'page_index' => $pageIndex]); } /** * 以页面为维度的数据统计接口 - * @param integer $page_id 指定页面的设备ID - * @param integer $begin_date 起始日期时间戳,最长时间跨度为30天,单位为秒 - * @param integer $end_date 结束日期时间戳,最长时间跨度为30天,单位为秒 + * @param integer $pageId 指定页面的设备ID + * @param integer $beginDate 起始日期时间戳,最长时间跨度为30天,单位为秒 + * @param integer $endDate 结束日期时间戳,最长时间跨度为30天,单位为秒 * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function totalPage($page_id, $begin_date, $end_date) + public function totalPage($pageId, $beginDate, $endDate) { $url = "https://api.weixin.qq.com/shakearound/statistics/page?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['page_id' => $page_id, 'begin_date' => $begin_date, 'end_date' => $end_date]); + return $this->callPostApi($url, ['page_id' => $pageId, 'begin_date' => $beginDate, 'end_date' => $endDate]); } /** * 编辑分组信息 - * @param integer $group_id 分组唯一标识,全局唯一 - * @param string $group_name 分组名称,不超过100汉字或200个英文字母 + * @param integer $groupId 分组唯一标识,全局唯一 + * @param string $groupName 分组名称,不超过100汉字或200个英文字母 * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function updateGroup($group_id, $group_name) + public function updateGroup($groupId, $groupName) { $url = "https://api.weixin.qq.com/shakearound/device/group/update?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['group_id' => $group_id, 'group_name' => $group_name]); + return $this->callPostApi($url, ['group_id' => $groupId, 'group_name' => $groupName]); } /** * 删除分组 - * @param integer $group_id 分组唯一标识,全局唯一 + * @param integer $groupId 分组唯一标识,全局唯一 * @return array * @throws \WeChat\Exceptions\InvalidResponseException * @throws \WeChat\Exceptions\LocalCacheException */ - public function deleteGroup($group_id) + public function deleteGroup($groupId) { $url = "https://api.weixin.qq.com/shakearound/device/group/delete?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['group_id' => $group_id]); + return $this->callPostApi($url, ['group_id' => $groupId]); } /** @@ -313,8 +294,7 @@ class Shake extends BasicWeChat public function getGroupList($begin = 0, $count = 10) { $url = "https://api.weixin.qq.com/shakearound/device/group/getlist?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['begin' => $begin, 'count' => $count]); + return $this->callPostApi($url, ['begin' => $begin, 'count' => $count]); } @@ -330,8 +310,7 @@ class Shake extends BasicWeChat public function getGroupDetail($group_id, $begin = 0, $count = 100) { $url = "https://api.weixin.qq.com/shakearound/device/group/getdetail?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['group_id' => $group_id, 'begin' => $begin, 'count' => $count]); + return $this->callPostApi($url, ['group_id' => $group_id, 'begin' => $begin, 'count' => $count]); } /** @@ -344,8 +323,7 @@ class Shake extends BasicWeChat public function addDeviceGroup(array $data) { $url = "https://api.weixin.qq.com/shakearound/device/group/adddevice?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -358,8 +336,6 @@ class Shake extends BasicWeChat public function deleteDeviceGroup(array $data) { $url = "https://api.weixin.qq.com/shakearound/device/group/deletedevice?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } - } \ No newline at end of file diff --git a/WeChat/Tags.php b/WeChat/Tags.php index 9fd6629..d0e9fef 100644 --- a/WeChat/Tags.php +++ b/WeChat/Tags.php @@ -33,8 +33,7 @@ class Tags extends BasicWeChat public function getTags() { $url = "https://api.weixin.qq.com/cgi-bin/tags/get?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpGetForJson($url); + return $this->callGetApi($url); } /** @@ -47,8 +46,7 @@ class Tags extends BasicWeChat public function createTags($name) { $url = "https://api.weixin.qq.com/cgi-bin/tags/create?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['tag' => ['name' => $name]]); + return $this->callPostApi($url, ['tag' => ['name' => $name]]); } /** @@ -62,8 +60,7 @@ class Tags extends BasicWeChat public function updateTags($id, $name) { $url = "https://api.weixin.qq.com/cgi-bin/tags/update?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['tag' => ['name' => $name, 'id' => $id]]); + return $this->callPostApi($url, ['tag' => ['name' => $name, 'id' => $id]]); } /** @@ -76,8 +73,7 @@ class Tags extends BasicWeChat public function deleteTags($tagId) { $url = 'https://api.weixin.qq.com/cgi-bin/tags/delete?access_token=ACCESS_TOKEN'; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['tag' => ['id' => $tagId]]); + return $this->callPostApi($url, ['tag' => ['id' => $tagId]]); } /** @@ -91,8 +87,7 @@ class Tags extends BasicWeChat public function batchTagging(array $openids, $tagId) { $url = 'https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging?access_token=ACCESS_TOKEN'; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['openid_list' => $openids, 'tagid' => $tagId]); + return $this->callPostApi($url, ['openid_list' => $openids, 'tagid' => $tagId]); } /** @@ -106,8 +101,7 @@ class Tags extends BasicWeChat public function batchUntagging(array $openids, $tagId) { $url = 'https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging?access_token=ACCESS_TOKEN'; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['openid_list' => $openids, 'tagid' => $tagId]); + return $this->callPostApi($url, ['openid_list' => $openids, 'tagid' => $tagId]); } /** @@ -120,7 +114,6 @@ class Tags extends BasicWeChat public function getUserTagId($openid) { $url = 'https://api.weixin.qq.com/cgi-bin/tags/getidlist?access_token=ACCESS_TOKEN'; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['openid' => $openid]); + return $this->callPostApi($url, ['openid' => $openid]); } } \ No newline at end of file diff --git a/WeChat/Template.php b/WeChat/Template.php index ad720c4..0410d29 100644 --- a/WeChat/Template.php +++ b/WeChat/Template.php @@ -27,17 +27,16 @@ class Template extends BasicWeChat { /** * 设置所属行业 - * @param string $industry_id1 公众号模板消息所属行业编号 - * @param string $industry_id2 公众号模板消息所属行业编号 + * @param string $industryId1 公众号模板消息所属行业编号 + * @param string $industryId2 公众号模板消息所属行业编号 * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function setIndustry($industry_id1, $industry_id2) + public function setIndustry($industryId1, $industryId2) { $url = "https://api.weixin.qq.com/cgi-bin/template/api_set_industry?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['industry_id1' => $industry_id1, 'industry_id2' => $industry_id2]); + return $this->callPostApi($url, ['industry_id1' => $industryId1, 'industry_id2' => $industryId2]); } /** @@ -49,8 +48,7 @@ class Template extends BasicWeChat public function getIndustry() { $url = "https://api.weixin.qq.com/cgi-bin/template/get_industry?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpGetForJson($url); + return $this->callGetApi($url); } /** @@ -64,8 +62,7 @@ class Template extends BasicWeChat public function addTemplate($templateIdShort, $keywordNameList = []) { $url = "https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['template_id_short' => $templateIdShort, 'keyword_name_list' => $keywordNameList]); + return $this->callPostApi($url, ['template_id_short' => $templateIdShort, 'keyword_name_list' => $keywordNameList]); } /** @@ -77,22 +74,20 @@ class Template extends BasicWeChat public function getAllPrivateTemplate() { $url = "https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpGetForJson($url); + return $this->callGetApi($url); } /** * 删除模板ID - * @param string $tpl_id 公众帐号下模板消息ID + * @param string $tplId 公众帐号下模板消息ID * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function delPrivateTemplate($tpl_id) + public function delPrivateTemplate($tplId) { $url = "https://api.weixin.qq.com/cgi-bin/template/del_private_template?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['template_id' => $tpl_id]); + return $this->callPostApi($url, ['template_id' => $tplId]); } /** @@ -105,9 +100,6 @@ class Template extends BasicWeChat public function send(array $data) { $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } - - } \ No newline at end of file diff --git a/WeChat/User.php b/WeChat/User.php index 14d4067..a69294b 100644 --- a/WeChat/User.php +++ b/WeChat/User.php @@ -37,8 +37,7 @@ class User extends BasicWeChat public function updateMark($openid, $remark) { $url = 'https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token=ACCESS_TOKEN'; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['openid' => $openid, 'remark' => $remark]); + return $this->callPostApi($url, ['openid' => $openid, 'remark' => $remark]); } /** @@ -52,8 +51,7 @@ class User extends BasicWeChat public function getUserInfo($openid, $lang = 'zh_CN') { $url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid={$openid}&lang={$lang}"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpGetForJson($url); + return $this->callGetApi($url); } /** @@ -71,8 +69,7 @@ class User extends BasicWeChat foreach ($openids as $openid) { $data['user_list'][] = ['openid' => $openid, 'lang' => $lang]; } - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, $data); + return $this->callPostApi($url, $data); } /** @@ -85,37 +82,34 @@ class User extends BasicWeChat public function getUserList($next_openid = '') { $url = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid={$next_openid}"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpGetForJson($url); + return $this->callGetApi($url); } /** * 获取标签下粉丝列表 * @param integer $tagid 标签ID - * @param string $next_openid 第一个拉取的OPENID + * @param string $nextOpenid 第一个拉取的OPENID * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function getUserListByTag($tagid, $next_openid = '') + public function getUserListByTag($tagid, $nextOpenid = '') { $url = 'https://api.weixin.qq.com/cgi-bin/user/tag/get?access_token=ACCESS_TOKEN'; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['tagid' => $tagid, 'next_openid' => $next_openid]); + return $this->callPostApi($url, ['tagid' => $tagid, 'next_openid' => $nextOpenid]); } /** * 获取公众号的黑名单列表 - * @param string $begin_openid + * @param string $beginOpenid * @return array * @throws Exceptions\InvalidResponseException * @throws Exceptions\LocalCacheException */ - public function getBlackList($begin_openid = '') + public function getBlackList($beginOpenid = '') { $url = "https://api.weixin.qq.com/cgi-bin/tags/members/getblacklist?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['begin_openid' => $begin_openid]); + return $this->callPostApi($url, ['begin_openid' => $beginOpenid]); } /** @@ -128,8 +122,7 @@ class User extends BasicWeChat public function batchBlackList(array $openids) { $url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchblacklist?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['openid_list' => $openids]); + return $this->callPostApi($url, ['openid_list' => $openids]); } /** @@ -142,8 +135,6 @@ class User extends BasicWeChat public function batchUnblackList(array $openids) { $url = "https://api.weixin.qq.com/cgi-bin/tags/members/batchunblacklist?access_token=ACCESS_TOKEN"; - $this->registerApi($url, __FUNCTION__, func_get_args()); - return $this->httpPostForJson($url, ['openid_list' => $openids]); + return $this->callPostApi($url, ['openid_list' => $openids]); } - } \ No newline at end of file