/** * 发送消息. * * @param string $openId * * @return bool */ public function to($openId) { if (empty($this->message)) { throw new Exception('未设置要发送的消息'); } $this->message->to = $openId; return $this->http->jsonPost(self::API_MESSAGE_SEND, $this->message->buildForStaff()); }
/** * 删除门店. * * @param int $storeId * * @return bool */ public function delete($storeId) { $params = array('poi_id' => $storeId); return $this->http->jsonPost(self::API_DELETE, $params); }
/** * 获取永久素材列表. * * example: * * { * "total_count": TOTAL_COUNT, * "item_count": ITEM_COUNT, * "item": [{ * "media_id": MEDIA_ID, * "name": NAME, * "update_time": UPDATE_TIME * }, * //可能会有多个素材 * ] * } * * @param string $type * @param int $offset * @param int $count * * @return array */ public function lists($type, $offset = 0, $count = 20) { $params = array('type' => $type, 'offset' => intval($offset), 'count' => min(20, $count)); return $this->http->jsonPost(self::API_FOREVER_LIST, $params); }
/** * 语义理解. * * @param string $keyword * @param array | string $categories * @param array $other * * @return Bag */ public function query($keyword, $categories, array $other = array()) { $params = array('query' => $keyword, 'category' => implode(',', (array) $categories), 'appid' => $this->appId); return new Bag($this->http->jsonPost(self::API_SEARCH, array_merge($params, $other))); }
/** * 添加个性化的菜单. * * @param mixed $menus * @param array $condition */ public function addConditional($menus, array $condition) { $menus = $this->extractMenus($menus); $this->http->jsonPost(self::API_CONDITIONAL_CREATE, array('button' => $menus, 'matchrule' => $condition)); return true; }
/** * 获取用户所在的组. * * @param string $openId * * @return int */ public function getGroup($openId) { $params = array('openid' => $openId); $response = $this->http->jsonPost(self::API_GROUP, $params); return $response['groupid']; }
/** * 创建二维码 * * @param string $actionName * @param array $actionInfo * @param bool $temporary * @param int $expireSeconds 过期天数,最多30天(2592000秒) * * @return Bag */ protected function create($actionName, $actionInfo, $temporary = true, $expireSeconds = null) { $expireSeconds !== null || ($expireSeconds = 7 * self::DAY); $http = new Http(new AccessToken($this->appId, $this->appSecret)); $params = array('action_name' => $actionName, 'action_info' => array('scene' => $actionInfo)); if ($temporary) { $params['expire_seconds'] = min($expireSeconds, 30 * self::DAY); } return new Bag($http->jsonPost(self::API_CREATE, $params)); }
/** * 查询群发消息发送状态 * * @param string $msgId 全消息ID * * @return array */ public function status($msgId) { return $this->http->jsonPost(self::API_GET, array('msg_id' => $msgId)); }
/** * 创建卡券货架. * * <pre> * $data: * { * "banner": "http://mmbiz.qpic.cn/mmbiz/iaL1LJM1mF9aRKPZJkmG8xXhiaHqkKSVMMWeN3hLut7X7h icFN", * "page_title": "惠城优惠大派送", * "can_share": true, * "scene": 'SCENE_H5', * "card_list": [ * { * 'card_id':"pXch-jnOlGtbuWwIO2NDftZeynRE", * 'thumb_url':"www.qq.com/a.jpg" * }, * { * 'card_id':"pXch-jnAN-ZBoRbiwgqBZ1RV60fI", * 'thumb_url':"www.qq.com/b.jpg" * } * ] * } * </pre> * * @param array $data * * @return array */ public function createLandingPage(array $data) { $defaultParams = array('banner' => '', 'page_title' => '', 'can_share' => true, 'scene' => 'SCENE_H5', 'card_list' => array(array('card_id' => '', 'thumb_url' => ''))); $params = array_merge($defaultParams, $data); return $this->http->jsonPost(self::API_LANDINGPAGE_CREATE, $params); }