回复微信服务器
@param array $msg 要发送的信息（默认取$this->_msg）
@param bool $return 是否返回信息而不抛出到浏览器（默认:否）
@return bool|string
434757
public function reply($msg = array(), $return = false)
    {
        if (empty($msg)) {
            if (empty($this->_msg)) {   //防止不先设置回复内容，直接调用reply方法导致异常
                return false;
            }
            $msg = $this->_msg;
        }
        $xmldata = Tools::arr2xml($msg);
        if ($this->encrypt_type == 'aes') { //如果来源消息为加密方式
            !class_exists('Prpcrypt', false) && require __DIR__ . '/Lib/Prpcrypt.php';
            $pc = new Prpcrypt($this->encodingAesKey);
            // 如果是第三方平台，加密得使用 component_appid
            $array = $pc->encrypt($xmldata, empty($this->config['component_appid']) ? $this->appid : $this->config['component_appid']);
            $ret = $array[0];
            if ($ret != 0) {
                Tools::log('Encrypt Error!', "ERR - {$this->appid}");
                return false;
            }
            $timestamp = time();
            $nonce = rand(77, 999) * rand(605, 888) * rand(11, 99);
            $encrypt = $array[1];
            $tmpArr = array($this->token, $timestamp, $nonce, $encrypt);
            sort($tmpArr, SORT_STRING);
            $signature = sha1(implode($tmpArr));
            $format = "<xml><Encrypt><![CDATA[%s]]></Encrypt><MsgSignature><![CDATA[%s]]></MsgSignature><TimeStamp>%s</TimeStamp><Nonce><![CDATA[%s]]></Nonce></xml>";
            $xmldata = sprintf($format, $encrypt, $signature, $timestamp, $nonce);
        }
        if ($return) {
            return $xmldata;
        }
        echo $xmldata;
    }
1029605
public function unauthorized($msg = '', $errorCode = null, $headers = [])
    {
        return $this->getErrorResponse($msg, $errorCode, self::HTTP_UNAUTHORIZED, $headers);
    }
358417
public function log($msg, $level = self::INFO, array $data = [])
    {
        if (is_numeric($level) && $level > $this->level) {
            return true;
        }

        $strData = $data ? json_encode($data) : '';

        if ($this->toSyslog) {
            return $this->sysLog($msg . ' ' . $strData, $level);
        }

        $label = self::getLevelName($level);
        $ds = FormatHelper::microTime(microtime(true));

        // [$this->getPidRole():$this->pid] $msg
        $logString = sprintf("[%s] [%s] %s %s\n", $ds, $label, trim($msg), $strData);

        // if not in daemon, print log to \STDOUT
        if (!$this->toConsole) {
            $this->stdout($logString, false);
        }

        if ($this->fileHandle) {
            $this->count++;
            $this->cache[] = Cli::clearColor($logString);

            if ($this->count >= $this->logThreshold || $this->fileIsChanged()) {
                $this->flush();
            }
        }

        return true;
    }
634555
public function print_csv_data($return = false) {
        fseek($this->fp, 0);
        $returnstring = '';
        while (($content = fgets($this->fp)) !== false) {
            if (!$return){
                echo $content;
            } else {
                $returnstring .= $content;
            }
        }
        if ($return) {
            return $returnstring;
        }
    }
1095708
public function display($return = false)
    {
        if ($this->getStatus()===null) {
            $this->setStatus(self::STATUS_OK);
        }
        if ($this->getMessage()===null) {
            $this->setMessage(
                array_key_exists($this->getStatus(), self::$default_messages) ?
                    self::$default_messages[$this->getStatus()] : ''
            );
        }
        if ($this->getResponse()->getStatus()===null) {
            $this->getResponse()->setStatus(HttpStatus::OK);
        }
        $this->getResponse()->setHeaders($this->headers);
        if ($return) {
            return $this->getResponse();
        } else {
            $this->getResponse()->send();
        }
    }
383739
function _try_multicall($msgs, $timeout, $method)
		{
			// Construct multicall message
			$calls = array();
			foreach($msgs as $msg)
			{
				$call['methodName'] = new xmlrpcval($msg->method(),'string');
				$numParams = $msg->getNumParams();
				$params = array();
				for($i = 0; $i < $numParams; $i++)
				{
					$params[$i] = $msg->getParam($i);
				}
				$call['params'] = new xmlrpcval($params, 'array');
				$calls[] = new xmlrpcval($call, 'struct');
			}
			$multicall = new xmlrpcmsg('system.multicall');
			$multicall->addParam(new xmlrpcval($calls, 'array'));

			// Attempt RPC call
			$result =& $this->send($multicall, $timeout, $method);

			if($result->faultCode() != 0)
			{
				// call to system.multicall failed
				return $result;
			}

			// Unpack responses.
			$rets = $result->value();

			if ($this->return_type == 'xml')
			{
					return $rets;
			}
			else if ($this->return_type == 'phpvals')
			{
				///@todo test this code branch...
				$rets = $result->value();
				if(!is_array($rets))
				{
					return false;		// bad return type from system.multicall
				}
				$numRets = count($rets);
				if($numRets != count($msgs))
				{
					return false;		// wrong number of return values.
				}

				$response = array();
				for($i = 0; $i < $numRets; $i++)
				{
					$val = $rets[$i];
					if (!is_array($val)) {
						return false;
					}
					switch(count($val))
					{
						case 1:
							if(!isset($val[0]))
							{
								return false;		// Bad value
							}
							// Normal return value
							$response[$i] = new xmlrpcresp($val[0], 0, '', 'phpvals');
							break;
						case 2:
							///	@todo remove usage of @: it is apparently quite slow
							$code = @$val['faultCode'];
							if(!is_int($code))
							{
								return false;
							}
							$str = @$val['faultString'];
							if(!is_string($str))
							{
								return false;
							}
							$response[$i] = new xmlrpcresp(0, $code, $str);
							break;
						default:
							return false;
					}
				}
				return $response;
			}
			else // return type == 'xmlrpcvals'
			{
				$rets = $result->value();
				if($rets->kindOf() != 'array')
				{
					return false;		// bad return type from system.multicall
				}
				$numRets = $rets->arraysize();
				if($numRets != count($msgs))
				{
					return false;		// wrong number of return values.
				}

				$response = array();
				for($i = 0; $i < $numRets; $i++)
				{
					$val = $rets->arraymem($i);
					switch($val->kindOf())
					{
						case 'array':
							if($val->arraysize() != 1)
							{
								return false;		// Bad value
							}
							// Normal return value
							$response[$i] = new xmlrpcresp($val->arraymem(0));
							break;
						case 'struct':
							$code = $val->structmem('faultCode');
							if($code->kindOf() != 'scalar' || $code->scalartyp() != 'int')
							{
								return false;
							}
							$str = $val->structmem('faultString');
							if($str->kindOf() != 'scalar' || $str->scalartyp() != 'string')
							{
								return false;
							}
							$response[$i] = new xmlrpcresp(0, $code->scalarval(), $str->scalarval());
							break;
						default:
							return false;
					}
				}
				return $response;
			}
		}
26815
private function message($msg, $def = ""){
    if ($def && !isset($msg[$def])) {
      $msg[$def] = array();
    }
    if ($def && empty($msg[$def])) {
      $msg[$def] = (object)$msg[$def];
    }

    if (!isset($msg["context"])) {
      $msg["context"] = array();
    }
    $msg["context"] = array_merge($this->getDefaultContext(), $msg["context"]);

    if (!isset($msg["timestamp"])) {
      $msg["timestamp"] = null;
    }
    $msg["timestamp"] = $this->formatTime($msg["timestamp"]);
    $msg["messageId"] = self::messageId();

    return $msg;
  }
829134
public static function success($msg)
    {
        $msg = 'Success: ' . $msg;
        $space = strlen($msg) + 4;
        $out  = static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_GREEN) . PHP_EOL;
        $out .= static::colorize('  ' . $msg . '  ', Color::FG_WHITE, Color::AT_BOLD, Color::BG_GREEN) . PHP_EOL;
        $out .= static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_GREEN) . PHP_EOL;

        return $out;
    }
412667
public function record($msg, $type = 'info', array $context = [])
    {
        if (is_string($msg)) {
            $replace = [];
            foreach ($context as $key => $val) {
                $replace['{' . $key . '}'] = $val;
            }

            $msg = strtr($msg, $replace);
        }

        $this->log[$type][] = $msg;

        if (PHP_SAPI == 'cli') {
            // 命令行日志实时写入
            $this->save();
        }

        return $this;
    }
1352096
public static function debug($msg)
    {
        if ($msg === 'open' || $msg === 'close') {
            self::$_debugOpen = $msg === 'open';
        } elseif (self::$_debugOpen === true) {
            $key = self::$_processKey === null ? '' : '[' . self::$_processKey . '] ';
            echo '[DEBUG] ', date('H:i:s '), $key, implode('', func_get_args()), self::CRLF;
        }
    }
327585
public function sendMsg($msg)
    {
        $apiUrl = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token='
            .$this->getAccessToken();
        $postStr = json_encode($msg, JSON_UNESCAPED_UNICODE);

        return $this->_curl($apiUrl, $postStr, 'post');
    }
767487
public function recallMessage($msgSeq)
    {
        $msgSeqList = is_array($msgSeq) ? $msgSeq : [$msgSeq];
        $request = new RecallGroupMessageRequest($this->groupId, $msgSeqList);
        $response = new BaseResponse();
        return $this->client->sendRequest($request, $response);
    }
1171308
public static function error($msg)
    {
        $msg = 'Error: ' . $msg;
        $space = strlen($msg) + 4;
        $out  = static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_RED) . PHP_EOL;
        $out .= static::colorize('  ' . $msg . '  ', Color::FG_WHITE, Color::AT_BOLD, Color::BG_RED) . PHP_EOL;
        $out .= static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_RED) . PHP_EOL;

        return $out;
    }
742593
public static function info($msg)
    {
        $msg = 'Info: ' . $msg;
        $space = strlen($msg) + 4;
        $out  = static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_BLUE) . PHP_EOL;
        $out .= static::colorize('  ' . $msg . '  ', Color::FG_WHITE, Color::AT_BOLD, Color::BG_BLUE) . PHP_EOL;
        $out .= static::colorize(str_pad(' ', $space), Color::FG_WHITE, Color::AT_BOLD, Color::BG_BLUE) . PHP_EOL;

        return $out;
    }
750984
final protected function mandatoryUserOrInlineMessageId(array &$return): array
    {
        if (empty($this->chat_id) && empty($this->message_id)) {
            $return[] = 'inline_message_id';
        }

        // On the other hand, chat_id and message_id are mandatory if inline_message_id is not filled in
        if (empty($this->inline_message_id)) {
            $return[] = 'chat_id';
            $return[] = 'message_id';
        }

        return $return;
    }
765016
public function fail($msg = 'Service Error', $status = 500)
    {
        if (is_string($msg)) {
            $messages = $this->standardMessage($msg);
        } else {
            $messages = $msg;
        }

        $reData = [
            'code'     => count($messages),
            'messages' => $messages,
        ];

        //打上Log
        Log::error('Service Error', $reData);

        return response()->json($reData, $status);
    }
1268396
protected function error($msg, array $bind = [])
    {
        foreach ($bind as $key => $value) {
            if (is_null($value)) {
                $value = 'NULL';
            } elseif (is_bool($value)) {
                $value = $value ? 'true' : 'false';
            }
            $msg .= "$key => $value\n";
        }
        return $msg;
    }