示例#1
0
 /**
  * 消息群发
  * @param  string|array $user    指定用户群
  * @param  string|array $toParty 指定部门
  * @param  string|array $toTag   指定标签 
  * @return 
  */
 public function to($user = '******', $toParty = null, $toTag = null)
 {
     if (empty($this->message)) {
         throw new Exception('未设置要发送的消息');
     }
     $this->message->agentid = $this->agentid;
     $this->message->touser = is_array($user) ? implode('|', $user) : $user;
     $this->message->toparty = is_array($toParty) ? implode('|', $toParty) : $toParty;
     $this->message->totag = is_array($toTag) ? implode('|', $toTag) : $toTag;
     return $this->http->jsonPost(self::API_SEND_MESSAGE, $this->message->buildForBroadcast());
 }
示例#2
0
 /**
  * 下载媒体文件.
  *
  * @param string $mediaId
  * @param string $filename
  *
  * @return mixed
  */
 public function download($mediaId, $filename = '')
 {
     $params = array('media_id' => $mediaId, 'agentid' => $this->agentId);
     $api = $this->forever ? self::API_FOREVER_GET : self::API_TEMPORARY_GET;
     $contents = $this->http->get($api, $params);
     $filename = $filename ? $filename : $mediaId;
     if (!is_array($contents)) {
         $ext = File::getStreamExt($contents);
         file_put_contents($filename . $ext, $contents);
         return $filename . $ext;
     } else {
         return $contents;
     }
 }
示例#3
0
 /**
  * 删除菜单
  *
  * @return bool
  */
 public function delete($agentId)
 {
     $this->http->get(self::API_DELETE . '?agentid=' . $agentId);
     return true;
 }
示例#4
0
 /**
  * userid转换成openid接口
  * @param  string $userId  userid
  * @param  int    $agentId 应用id
  * @return array
  */
 public function toOpenId($userId, $agentId)
 {
     $params = array('userid' => $userId, 'agentid' => $agentId);
     return $this->http->jsonPost(self::API_TO_OPENID, $params);
 }
示例#5
0
 /**
  * 获取部门成员(详情)
  * @param  integer $departmentId 部门id
  * @param  integer $fetchChild   是否递归获取子部门下面的成员
  * @param  integer $status       成员类型 可叠加
  * @return Bag                 
  */
 public function lists($departmentId, $fetchChild = 1, $status = 1)
 {
     $params = array('department_id' => $departmentId, 'fetch_child' => $fetchChild, 'status' => $status);
     return new Bag($this->http->get(self::API_LIST, $params));
 }