发送图文信息,必须从图文库里选取消息ID发送
@param  string $id      用户的uid(即FakeId)
@param  string $msgid 图文消息id
970627
public function sendNews($id,$msgid)
	{
		$send_snoopy = new Snoopy; 
		$post = array();
		$post['tofakeid'] = $id;
		$post['type'] = 10;
		$post['token'] = $this->_token;
		$post['fid'] = $msgid;
		$post['appmsgid'] = $msgid;
		$post['error'] = 'false';
		$post['ajax'] = 1;
        $send_snoopy->referer = "https://mp.weixin.qq.com/cgi-bin/singlemsgpage?fromfakeid={$id}&msgid=&source=&count=20&t=wxm-singlechat&lang=zh_CN";
		$send_snoopy->rawheaders['Cookie']= $this->cookie;
		$submit = "https://mp.weixin.qq.com/cgi-bin/singlesend?t=ajax-response";
		$send_snoopy->submit($submit,$post);
		$this->log($send_snoopy->results);
		return $send_snoopy->results;
	}
1326707
@NotNull
    @ObjectiveCName("makeAdminCommandWithGid:withUid:")
    public Command<Void> makeAdmin(final int gid, final int uid) {
        return callback -> modules.getGroupsModule().makeAdmin(gid, uid)
                .then(v -> callback.onResult(v))
                .failure(e -> callback.onError(e));
    }
487049
public function channelGroupPermList($cgid, $permsid = FALSE)
  {
    return $this->execute("channelgrouppermlist", array("cgid" => $cgid, $permsid ? "-permsid" : null))->toAssocArray($permsid ? "permsid" : "permid");
  }
65351
public function updateGroupUser($uid, $gid) {
		$user = WechatUser::findOne($uid);
		if(!$user) {
			throw new ErrorException('数据查询失败');
		}

		if($user->groupid == $gid) {
			return true;
		}

		$data = $this->getData('/cgi-bin/groups/members/update', [
			'access_token' => $this->getAccessToken(),
		], Json::encode([
			'openid' => $user->openid,
			'to_groupid' => $gid,
		]));

		$result = $this->errcode == 0;
		if($result && $user->group->updateCounters(['count' => -1])) {
			$user->groupid = $gid;
			if($user->save()) {
				$user->refresh();
				return $user->group->updateCounters(['count' => 1]);
			}
		}

		return $result;
	}
1107065
public void fail(Object msgId) {
		LOG.warn("Message failed: " + msgId);
        this.pendingMessages.clear();
        this.toCommit.clear();
		synchronized(this.recoveryMutex){
		    this.hasFailures = true;
		}
	}
752522
public function sendToUser($user_id, array $msg) {
        //检查redis ping 防止掉线
        $fid = $this->userIdToFid($user_id);
        if (!$fid) {
            return null;
        }
        $fid_server = explode('@', $fid);
        $host_name = $fid_server[ 0 ];
        $fid = $fid_server[ 1 ];
        if ($host_name == $this->host_name) {
            if (!$this->server->exist($fid)) {
                //断开
                $this->server->close($fid);
                $redis = Cache::redis();
                $redis->hDel('user_id_#_fid', $user_id);
                $redis->hDel('fid_#_user_id', $fid);
                Cache::release();
                return false;
            }
            $this->server->push($fid, json_encode($msg));
        } else {
            try {
                //通过集群中的其他服务器推送
                Http::put('http://' . $host_name . ':' . $this->config[ 'port' ] . '/open/push', [], ['fid' => $fid,
                                                                                                      'msg' => json_encode($msg),
                                                                                                      'secret' => $this->config[ 'secret' ]]);
            } catch (\Exception $exception) {
            } catch (\Error $exception) {
            }
        }
        return null;
    }
344433
protected void addMsgToLogHandler(String msgId, String handlerId) {
        Set<String> logHandlerIdSet = getOrCreateLogHandlerIdSet(msgId);
        logHandlerIdSet.add(handlerId);
    }
401044
public void updateMessageListForHandler(String msgIds, String handlerId) {
        if (msgIds == null) {
            return; // Should never happen, but avoid NPEs
        }

        String[] msgStr = msgIds.split(",");
        ArrayList<String> newMsgList = new ArrayList<String>(Arrays.asList(msgStr));
        newMsgList.remove(""); // Ignore blank value

        // Get the list of existing handlers mapped to this message ID.
        ArrayList<String> prevMsgList = previousHandlerMessageMap.get(handlerId);
        {
            if (prevMsgList == null) {
                prevMsgList = new ArrayList<String>();
            }
        }

        if (prevMsgList.equals(newMsgList)) {
            return; // No change = nothing to do here, skip issuing message
        }

        getMessageRouter(); // Ensure router is not null

        // Check for new messages and add them to the list for the handler
        ArrayList<String> addedMsgs = new ArrayList<String>(newMsgList);
        addedMsgs.removeAll(prevMsgList);

        for (String msgId : addedMsgs) {
            msgRouter.addMsgToLogHandler(msgId, handlerId);
        }

        // Check for removed messages and remove them from the list for the handler
        ArrayList<String> removedMsgs = new ArrayList<String>(prevMsgList);
        removedMsgs.removeAll(newMsgList);

        for (String msgId : removedMsgs) {
            msgRouter.removeMsgFromLogHandler(msgId, handlerId);
        }

        // Save the new map for the next config change
        previousHandlerMessageMap.put(handlerId, newMsgList);

        // Notify that there was a change in this handler's messages
        String setOfIds = "";
        for (String msg : newMsgList) {
            if (!setOfIds.equals("")) {
                setOfIds = setOfIds.concat(" ");
            }
            setOfIds = setOfIds.concat(msg);
        }
        Tr.info(tc, "MSG_ROUTER_UPDATED", new Object[] { handlerId, setOfIds });
    }
593044
public void setGID(String gid) {

		if (version > 3) {
			flags |= SSH_FILEXFER_ATTR_OWNERGROUP;
		} else
			flags |= SSH_FILEXFER_ATTR_UIDGID;
		this.gid = gid;
	}
515127
public function serverGroupPermRemove($sgid, $permid)
  {
    if(!is_array($permid))
    {
      $permident = (is_numeric($permid)) ? "permid" : "permsid";
    }
    else
    {
      $permident = (is_numeric(current($permid))) ? "permid" : "permsid";
    }

    $this->execute("servergroupdelperm", array("sgid" => $sgid, $permident => $permid));
  }
1265072
public function bindTraceId($id, $is_pid = false)
    {
        if (_CLI_) {
            if ($is_pid) {
                $pid = $id;
                $id  = get_co_id();
            } else {
                $pid = get_co_id();
            }
            if ($pid == -1 && _DEBUG_) {
                echo 'warn bindTraceId false : ' . $id . "\n";
            }
            if (!isset($this->_traceId[$pid]) && _DEBUG_) {
                echo 'warn bindTraceId get pid false : ' . $pid . "\n";
            }
            $this->_traceId[$id] = $this->_traceId[$pid];
        }
        return $id;
    }
971607
@Override
  protected String dbgId()
  {
    HttpContainer httpSystem = http();
    
    String serverId = "";
    
    if (httpSystem != null) {
      serverId = httpSystem.getServerDisplayName();
    }
    
    long connId = connectionId();

    if ("".equals(serverId))
      return "Http[" + connId + "] ";
    else
      return "Http[" + serverId + ", " + connId + "] ";
  }
63648
public function markElect(string $msgId, int $index, int $commentId)
    {
        $params = [
            'msg_data_id' => $msgId,
            'index' => $index,
            'user_comment_id' => $commentId,
        ];

        return $this->httpPostJson('cgi-bin/comment/markelect', $params);
    }
795296
public function send($openid, $msg)
    {
        // 获取消息类型
        $msg_type = '';
        if (gettype($msg)=='string') {
            $msg_type = 'text_simple';
        } elseif (gettype($msg)=='array') {
            $msg_type = $msg['type'];
        }

        switch ($msg_type) {
            /**
             * 1.1 发送文本消息(简洁输入)
             *
             * Examples:
             * ```
             * $api->send('ocNtAt_K8nRlAdmNEo_R0WVg_rRw', 'hello world!');
             * ```
             */
            case 'text_simple':
                $xml = sprintf('{'.
                        '"touser":"%s",'.
                        '"msgtype":"text",'.
                        '"text":{'.
                            '"content":"%s"'.
                        '}}',
                        $openid,
                        $msg);
                break;

            /**
             * 1.2 发送文本消息
             *
             * Examples:
             * ```
             * $api->send('ocNtAt_K8nRlAdmNEo_R0WVg_rRw', array(
             *  'type' => 'text',
             *  'content' => 'hello world!'
             * ));
             * ```
             */
            case 'text':
                $xml = sprintf('{'.
                        '"touser":"%s",'.
                        '"msgtype":"text",'.
                        '"text":{'.
                            '"content":"%s"'.
                        '}%s}', 
                        $openid,
                        $msg['content'],
                        isset($msg['kf_account']) ? ',"customservice":{"kf_account": "'.$msg['kf_account'].'"}' : '');
                break;

            /**
             * 2 发送图片消息
             *
             * Examples:
             * ```
             * $api->send('ocNtAt_K8nRlAdmNEo_R0WVg_rRw', array(
             *  'type' => 'image',
             *  'media_id' => 'Uq7OczuEGEyUu--dYjg7seTm-EJTa0Zj7UDP9zUGNkVpjcEHhl7tU2Mv8mFRiLKC'
             * ));
             * ```
             */
            case 'image':
                $xml = sprintf('{'.
                        '"touser":"%s",'.
                        '"msgtype":"image",'.
                        '"image":{'.
                            '"media_id":"%s"'.
                        '}%s}', 
                        $openid,
                        $msg['media_id'],
                        isset($msg['kf_account']) ? ',"customservice":{"kf_account": "'.$msg['kf_account'].'"}' : '');
                break;

            /**
             * 3 发送语音消息
             *
             * Examples:
             * ```
             * $api->send('ocNtAt_K8nRlAdmNEo_R0WVg_rRw', array(
             *  'type' => 'voice',
             *  'media_id' => 'rVT43tfDwjh4p1BV2gJ5D7Zl2BswChO5L_llmlphLaTPytcGcguBAEJ1qK4cg4r_'
             *  ));
             * ```
             */
            case 'voice':
                $xml = sprintf('{'.
                        '"touser":"%s",'.
                        '"msgtype":"voice",'.
                        '"voice":{'.
                            '"media_id":"%s"'.
                        '}%s}', 
                        $openid,
                        $msg['media_id'],
                        isset($msg['kf_account']) ? ',"customservice":{"kf_account": "'.$msg['kf_account'].'"}' : '');
                break;

            /**
             * 4 发送视频消息
             *
             * Examples:
             * ```
             * $api->send('ocNtAt_K8nRlAdmNEo_R0WVg_rRw', array(
             *  'type' => 'video',
             *  'media_id' => 'yV0l71NL0wtpRA8OMX0-dBRQsMVyt3fspPUzurIS3psi6eWOrb_WlEeO39jasoZ8',
             *  'thumb_media_id' => '7ct_DvuwZXIO9e9qbIf2ThkonUX_FzLAoqBrK-jzUboTYJX0ngOhbz6loS-wDvyZ',     // 可选(无效, 官方文档好像写错了)
             *  'title' => '视频消息的标题',           // 可选
             *  'description' => '视频消息的描述'      // 可选
             * ));
             * ```
             */         
            case 'video':
                $xml = sprintf('{'.
                        '"touser":"%s",'.
                        '"msgtype":"video",'.
                        '"video":{'.
                            '"media_id":"%s",'.
                            '"thumb_media_id":"%s",'.
                            '"title":"%s",'.
                            '"description":"%s"'.
                        '}%s}', 
                        $openid,
                        $msg['media_id'],
                        $msg['thumb_media_id'],
                        isset($msg['title']) ? $msg['title'] : '',
                        isset($msg['description']) ? $msg['description'] : '',
                        isset($msg['kf_account']) ? ',"customservice":{"kf_account": "'.$msg['kf_account'].'"}' : '');
                break;

            /**
             * 5 发送音乐消息
             *
             * Examples:
             * ```
             * $api->send('ocNtAt_K8nRlAdmNEo_R0WVg_rRw', array(
             *  'type' => 'music',
             *  'title' => '音乐标题',                      //可选
             *  'description' => '音乐描述',                //可选
             *  'music_url' => 'http://me.diary8.com/data/music/2.mp3',     //可选
             *  'hqmusic_url' => 'http://me.diary8.com/data/music/2.mp3',   //可选
             *  'thumb_media_id' => 'O39wW0ZsXCb5VhFoCgibQs5PupFb6VZ2jH5A8gHUJCJz2Qmkrb7objoTue7bGTGQ',
             * ));
             * ```
             */         
            case 'music':
                $xml = sprintf('{'.
                        '"touser":"%s",'.
                        '"msgtype":"music",'.
                        '"music":{'.
                            '"title":"%s",'.
                            '"description":"%s",'.
                            '"musicurl":"%s",'.
                            '"hqmusicurl":"%s",'.
                            '"thumb_media_id":"%s"'.
                        '}%s}', 
                        $openid,
                        isset($msg['title']) ? $msg['title'] : '',
                        isset($msg['description']) ? $msg['description'] : '',
                        isset($msg['music_url']) ? $msg['music_url'] : '',
                        isset($msg['hqmusic_url']) ? $msg['hqmusic_url'] : '',
                        $msg['thumb_media_id'],
                        isset($msg['kf_account']) ? ',"customservice":{"kf_account": "'.$msg['kf_account'].'"}' : '');
                break;

            /**
             * 6 发送图文消息
             *
             * Examples:
             * ```
             * $api->send($msg->FromUserName, array(
             *  'type' => 'news',
             *  'articles' => array(
             *      array(
             *          'title' => '图文消息标题1',                           //可选
             *          'description' => '图文消息描述1',                     //可选
             *          'picurl' => 'http://me.diary8.com/data/img/demo1.jpg',  //可选
             *          'url' => 'http://www.example.com/'                      //可选
             *      ),
             *      array(
             *          'title' => '图文消息标题2',
             *          'description' => '图文消息描述2',
             *          'picurl' => 'http://me.diary8.com/data/img/demo2.jpg',
             *          'url' => 'http://www.example.com/'
             *      ),
             *      array(
             *          'title' => '图文消息标题3',
             *          'description' => '图文消息描述3',
             *          'picurl' => 'http://me.diary8.com/data/img/demo3.jpg',
             *          'url' => 'http://www.example.com/'
             *      )
             *  ),
             *  'kf_account' => 'test1@kftest'      // 可选(指定某个客服发送, 会显示这个客服的头像)
             * ));
             * ```
             */
            case 'news':
                $articles = array();
                foreach ($msg['articles'] as $article) {
                    array_push($articles, sprintf('{'.
                        '"title":"%s",'.
                        '"description":"%s",'.
                        '"url":"%s",'.
                        '"picurl":"%s"'.
                        '}',
                        $article['title'],
                        $article['description'],
                        $article['url'],
                        $article['picurl']));
                }
                $articles = implode(",", $articles);
                $xml = sprintf('{'.
                        '"touser":"%s",'.
                        '"msgtype":"news",'.
                        '"news":{"articles": [%s]}%s}',
                        $openid,
                        $articles,
                        isset($msg['kf_account']) ? ',"customservice":{"kf_account": "'.$msg['kf_account'].'"}' : '');
                break;

            /**
             * 0 异常消息处理
             *
             */ 
            default:
                return Error::code('ERR_MEG_TYPE');
                break;
        }

        $url = self::API_DOMAIN . 'cgi-bin/message/custom/send?access_token=' . $this->get_access_token();
        $res = HttpCurl::post($url, $xml, 'json');
        // 异常处理: 获取access_token网络错误
        if ($res === false) {
            return Error::code('ERR_GET');
        }
        // 判断是否调用成功
        if ($res->errcode == 0) {
            return array(null, true);
        } else {
            return array($res, null);
        }
    }
108820
@Override
  public Guid guid() throws IOException {
    StringBuilder uniqueString = new StringBuilder();
    uniqueString.append(getFileStatus().getModificationTime());
    uniqueString.append(getFileStatus().getLen());
    uniqueString.append(getFileStatus().getPath());
    return Guid.fromStrings(uniqueString.toString());
  }
51405
protected function removeFuzzyFlagForMsgId($msgid)
    {
        if (!isset($this->entriesAsArrays[$msgid])) {
            throw new \Exception('Entry does not exist');
        }
        if ($this->entriesAsArrays[$msgid]['fuzzy']) {
            $flags = $this->entriesAsArrays[$msgid]['flags'];
            unset($flags[array_search('fuzzy', $flags, true)]);
            $this->entriesAsArrays[$msgid]['flags'] = $flags;
            $this->entriesAsArrays[$msgid]['fuzzy'] = false;
        }
    }
629739
public function guid($guid, $isPermalink = false)
    {
        $this->guid = $guid;
        $this->isPermalink = $isPermalink;

        return $this;
    }