Example #1
0
 /**
  * 设置菜单.
  *
  * @return bool
  */
 public function set($menus)
 {
     if ($menus instanceof Closure) {
         $menus = $menus($this);
     }
     if (!is_array($menus)) {
         throw new Exception('子菜单必须是数组或者匿名函数返回数组', 1);
     }
     $menus = $this->extractMenus($menus);
     $this->http->jsonPost(self::API_CREATE, ['button' => $menus]);
     return true;
 }
Example #2
0
 /**
  * 发送消息
  *
  * @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());
 }
Example #3
0
 /**
  * 创建二维码
  *
  * @param string $actionName
  * @param array  $actionInfo
  * @param bool   $temporary
  * @param int    $expireSeconds
  *
  * @return Collection
  */
 protected function create($actionName, $actionInfo, $temporary = true, $expireSeconds = null)
 {
     $expireSeconds !== null || ($expireSeconds = 7 * self::DAY);
     $params = array('action_name' => $actionName, 'action_info' => array('scene' => $actionInfo));
     if ($temporary) {
         $params['expire_seconds'] = min($expireSeconds, 7 * self::DAY);
     }
     return new Collection($this->http->jsonPost(self::API_CREATE, $params));
 }
Example #4
0
 /**
  * 发送消息
  *
  * @param string $openId
  *
  * @return bool
  */
 public function totag($tagid, $agentid = 1)
 {
     if (empty($this->message)) {
         throw new Exception('未设置要发送的消息');
     }
     $this->message->totag = $tagid;
     $this->message->agentid = $agentid;
     $message_body = $this->message->buildForStaff();
     return $this->http->jsonPost(self::API_MESSAGE_SEND, $message_body);
 }
Example #5
0
 /**
  * @param string $to
  * @param string $templateId
  * @param array  $data
  * @param string $url
  * @param string $color
  *
  * @return int
  */
 public function send($to = null, $templateId = null, array $data = array(), $url = null, $color = '#FF0000')
 {
     $params = array('touser' => $to, 'template_id' => $templateId, 'url' => $url, 'topcolor' => $color, 'data' => $data);
     foreach ($params as $key => $value) {
         if (empty($value) && empty($this->message[$key])) {
             throw new Exception("消息属性 '{$key}' 不能为空!");
         }
         $params[$key] = empty($value) ? $this->message[$key] : $value;
     }
     $params['data'] = $this->formatData($params['data']);
     $result = $this->http->jsonPost(self::API_SEND_NOTICE, $params);
     return $result['msgid'];
 }
Example #6
0
 /**
  * Batch move users to a group.
  *
  * @param array $openIds
  * @param int   $groupId
  *
  * @return bool
  */
 public function moveUsers(array $openIds, $groupId)
 {
     $params = ['openid_list' => $openIds, 'to_groupid' => $groupId];
     $this->http->jsonPost(self::API_MEMBER_BATCH_UPDATE, $params);
     return true;
 }
Example #7
0
 /**
  * 转短链接
  *
  * @param string $url
  *
  * @return string
  */
 public function short($url)
 {
     $params = array('action' => 'long2short', 'long_url' => $url);
     $response = $this->http->jsonPost(self::API_SHORT_URL, $params);
     return $response['short_url'];
 }
Example #8
0
 /**
  * 查询数据.
  *
  * @param string $api
  * @param string $from
  * @param string $to
  *
  * @return array
  */
 protected function query($api, $from, $to)
 {
     $params = ['begin_date' => $from, 'end_date' => $to];
     $result = $this->http->jsonPost($api, $params);
     return $result['list'];
 }
Example #9
0
 /**
  * 设置成员新消息免打扰
  *
  * @param  array $user_mute_list 成员新消息免打扰参数,数组,最大支持10000个成员
  * @return array
  */
 public function setmute($user_mute_list)
 {
     $params = array('user_mute_list' => $user_mute_list);
     return $this->http->jsonPost(self::API_SETMUTE, $params);
 }
Example #10
0
 /**
  * 删除标签成员
  * @param  int    $tagId     
  * @param  array  $userList  
  * @param  array  $partyList
  * @return array 
  */
 public function deleteTagUser($tagId, $userList, $partyList)
 {
     $params = array('tagid' => $tagId, 'userlist' => $userList, 'partylist' => $partyList);
     return $this->http->jsonPost(self::API_DELETE_USER, $params);
 }
Example #11
0
 /**
  * 删除门店.
  *
  * @param int $storeId
  *
  * @return bool
  */
 public function delete($storeId)
 {
     $params = ['poi_id' => $storeId];
     return $this->http->jsonPost(self::API_DELETE, $params);
 }
Example #12
0
 /**
  * 在线值机
  *
  * <pre>
  * $data:
  * {
  *     "code": "198374613512",
  *     "card_id":"p1Pj9jr90_SQRaVqYI239Ka1erkI",
  *     "passenger_name": "乘客姓名",
  *     "class": "舱等",
  *     "seat": "座位号",
  *     "etkt_bnr": "电子客票号", "qrcode_data": "二维码数据", "is_cancel ": false
  * }
  * </pre>
  *
  * @param string $cardId
  * @param array  $data
  *
  * @return bool
  */
 public function checkin($cardId, array $data)
 {
     $params = array_merge(array('card_id' => $cardId), $data);
     return $this->http->jsonPost(self::API_BOARDING_PASS_CHECKIN, $params);
 }
Example #13
0
 /**
  * 更新部门
  * @param  string  $name     部门名称
  * @param  integer $parentid 父亲部门id
  * @param  integer $order    在父部门中的次序值
  * @param  integer $id       部门id (可以自动生成)
  * @return integer           部门id
  */
 public function update($id, $name, $parentid = 1, $order = null)
 {
     $params = array('name' => $name, 'parentid' => $parentid, 'order' => $order, 'id' => $id);
     return $this->http->jsonPost(self::API_UPDATE, $params);
 }
Example #14
0
 /**
  * 获取永久素材列表.
  *
  * 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 = ['type' => $type, 'offset' => intval($offset), 'count' => min(20, $count)];
     return $this->http->jsonPost(self::API_FOREVER_LIST, $params);
 }
Example #15
0
 /**
  * Get user's group id.
  *
  * @param string $openId
  *
  * @return int
  */
 public function getGroup($openId)
 {
     $params = ['openid' => $openId];
     $response = $this->http->jsonPost(self::API_GROUP, $params);
     return $response['groupid'];
 }
Example #16
0
 /**
  * 语义理解.
  *
  * @param string         $keyword
  * @param array | string $categories
  * @param array          $other
  *
  * @return Collection
  */
 public function query($keyword, $categories, array $other = [])
 {
     $params = ['query' => $keyword, 'category' => implode(',', (array) $categories), 'appid' => $this->appId];
     return new Collection($this->http->jsonPost(self::API_CREATE, array_merge($params, $other)));
 }
 /**
  * 删除群发消息
  *
  * @param $msg_id
  * @return mixed
  */
 public function delete($msg_id)
 {
     return $this->http->jsonPost(self::API_DELETE, ['msg_id' => $msg_id]);
 }
Example #18
0
 /**
  * 设置企业号应用
  *
  * @param  array $agentInfo 应用信息 具体数据参考微信接口
  * @return array
  */
 public function set(array $agentInfo)
 {
     return $this->http->jsonPost(self::API_SET, $agentInfo);
 }