发送单聊模板消息方法（一个用户向多个用户发送不同消息内容，单条消息最大 128k。每分钟最多发送 6000 条信息，每次发送用户上限为 1000 人。） 方法
        @param  templateMessage:单聊模版消息。
	 
        @return code:返回码，200 为正常。
        @return errorMessage:错误信息。
557534
def publishTemplate(self, templateMessage):
        

        desc = {
            "name": "CodeSuccessReslut",
            "desc": " http 成功返回结果",
            "fields": [{
                "name": "code",
                "type": "Integer",
                "desc": "返回码，200 为正常。"
            }, {
                "name": "errorMessage",
                "type": "String",
                "desc": "错误信息。"
            }]
        }
        r = self.call_api(
            method=('API', 'POST', 'application/json'),
            action='/message/private/publish_template.json',
            params=templateMessage)
        return Response(r, desc)
458138
public String getMessageCode(BaseMessage externalTrxMessage)
    {
        if (externalTrxMessage.getMessageHeader() == null)
            return null;
        return (String)externalTrxMessage.getMessageHeader().get(TrxMessageHeader.MESSAGE_CODE);
    }
1316284
public int writeTemplate(String template, ValueSet vs) {
        int returnCode = htod.writeTemplate(template, vs);
        if (returnCode == HTODDynacache.DISK_EXCEPTION) {
            stopOnError(this.htod.diskCacheException);
        }
        return returnCode;
    }
1066361
public String createErrorMessage(RecognitionException e)
	        {
	        StringBuilder message = new StringBuilder();
	                message.append( source + ":"+e.line+":"+e.charPositionInLine+" ");
	                if ( e instanceof MismatchedTokenException ) {
	                        MismatchedTokenException mte = (MismatchedTokenException)e;
	                        message.append("mismatched token: "+
	                                                           e.token+
	                                                           "; expecting type "+
	                                                           tokenNames[mte.expecting]);
	                }
	                else if ( e instanceof MismatchedTreeNodeException ) {
	                        MismatchedTreeNodeException mtne = (MismatchedTreeNodeException)e;
	                        message.append("mismatched tree node: "+
	                                                           mtne.node+
	                                                           "; expecting type "+
	                                                           tokenNames[mtne.expecting]);
	                }
	                else if ( e instanceof NoViableAltException ) {
	                        NoViableAltException nvae = (NoViableAltException)e;
	            message.append( "Unexpected token '" + e.token.getText() + "'" );
	                        /*
	                        message.append("decision=<<"+nvae.grammarDecisionDescription+">>"+
	                                                           " state "+nvae.stateNumber+
	                                                           " (decision="+nvae.decisionNumber+
	                                                           ") no viable alt; token="+
	                                                           e.token);
	                                                           */
	                }
	                else if ( e instanceof EarlyExitException ) {
	                        EarlyExitException eee = (EarlyExitException)e;
	                        message.append("required (...)+ loop (decision="+
	                                                           eee.decisionNumber+
	                                                           ") did not match anything; token="+
	                                                           e.token);
	                }
	                else if ( e instanceof MismatchedSetException ) {
	                        MismatchedSetException mse = (MismatchedSetException)e;
	                        message.append("mismatched token '"+
	                                                           e.token+
	                                                           "' expecting set "+mse.expecting);
	                }
	                else if ( e instanceof MismatchedNotSetException ) {
	                        MismatchedNotSetException mse = (MismatchedNotSetException)e;
	                        message.append("mismatched token '"+
	                                                           e.token+
	                                                           "' expecting set "+mse.expecting);
	                }
	                else if ( e instanceof FailedPredicateException ) {
	                        FailedPredicateException fpe = (FailedPredicateException)e;
	                        message.append("rule "+fpe.ruleName+" failed predicate: {"+
	                                                           fpe.predicateText+"}?");
	        }
	                   return message.toString();
	        }
722465
private String generateInvalidErrorMessage(Object[] enumValues, String testValue)
    {
        StringBuffer errorMessage = new StringBuffer("Unable to convert value [" + testValue + "].");

        errorMessage.append(" Allowed values are (case insensitive) ");

        StringBuffer valueList = new StringBuffer();

        int index = 1;
        for (Object enumValue : enumValues) {
            if (valueList.length() > 0) {
                if (++index == enumValues.length) {
                    valueList.append(" or ");
                } else {
                    valueList.append(", ");
                }
            }

            valueList.append('"');
            valueList.append(enumValue);
            valueList.append('"');
        }

        errorMessage.append(valueList);
        errorMessage.append('.');

        return errorMessage.toString();
    }
426915
@Nonnull
    public String getMessageWithoutPrefix() {
        BugPattern bugPattern = getBugPattern();
        String pattern, shortPattern;

        pattern = getLongDescription();
        shortPattern = bugPattern.getShortDescription();
        try {
            FindBugsMessageFormat format = new FindBugsMessageFormat(pattern);
            return format.format(annotationList.toArray(new BugAnnotation[annotationList.size()]), getPrimaryClass());
        } catch (RuntimeException e) {
            AnalysisContext.logError("Error generating bug msg ", e);
            return shortPattern + " [Error generating customized description]";
        }
    }
412712
function getTemplate(message, ec_level) {
    var i = 1;
    var len;

    if (message.data1) {
        len = Math.ceil(message.data1.length / 8);
    } else {
        i = 10;
    }
    for (/* i */; i < 10; i++) {
        var version = versions[i][ec_level];
        if (version.data_len >= len) {
            return _deepCopy(version);
        }
    }

    if (message.data10) {
        len = Math.ceil(message.data10.length / 8);
    } else {
        i = 27;
    }
    for (/* i */; i < 27; i++) {
        var version = versions[i][ec_level];
        if (version.data_len >= len) {
            return _deepCopy(version);
        }
    }

    len = Math.ceil(message.data27.length / 8);
    for (/* i */; i < 41; i++) {
        var version = versions[i][ec_level];
        if (version.data_len >= len) {
            return _deepCopy(version);
        }
    }
    throw new Error("Too much data");
}
1342437
function getErrorCode(message) {
    var tokens = message.split('\n'),
        token;
    while (tokens.length) {
        token = tokens.shift();
        if (token.indexOf('CODE:') === 0) {
            token = parseInt(token.replace('CODE:', ''));
            if (Type.isNumber(token) && !isNaN(token)) {
                return token;
            }
        }
    }
    return 500;
}
764522
String readBodyAndValidateForNumber() {
        String messageContent = readBodyAsString();
        if (messageContent == null || messageContent.isEmpty()) {
            throw new RuntimeException("Message is empty");
        }
        // Check if content is a number
        for (int i = 0; i < messageContent.length(); i++) {
            if (! Character.isDigit(messageContent.charAt(i))) {
                throw new RuntimeException("Message is not a number");
            }
        }
        return messageContent;
    }
419657
public static function getCodeByMessage(string $errorMessage): int
    {
        $code = array_search($errorMessage, self::MESSAGES);
        if ($code === false) {
            $code = self::UNKNOWN_ERROR;
        }
        return (int)$code;
    }
875607
public static <T extends CharSequence> T validatePlateNumber(T value, String errorMsg) throws ValidateException {
		if (false == isPlateNumber(value)) {
			throw new ValidateException(errorMsg);
		}
		return value;
	}
794145
public function send_template_msg($openid , $template_id , $template_url , $datas = NULL){
    
        $url = self::API_URI . self::TEMPLATE_MESSAGE_SEND;
        $param['access_token'] = $this->get_access_token();
    
        $template_send_url = $this->create_url($url, $param);
    
        $fields['touser'] = $openid;
        $fields['template_id'] = $template_id;
        $fields['url'] = $template_url;
        $data = array();
        foreach ($datas as $k=>$v){
            $d['value'] = $v;
            $d['color'] = '#173177';
    
            $data[$k] = $d;
        }
        if ($data){
            $fields['data'] = $data;
        }
    
        $fields = json_encode($fields , true);
        $res = $this->http_post($template_send_url, $fields);
    
        return $this->return_data($res);
    }
1056481
public MAPErrorMessage createMessageFromErrorCode(Long errorCode) {
        long ec = (long) errorCode;
        switch ((int) ec) {
            case MAPErrorCode.unexpectedDataValue:
            case MAPErrorCode.dataMissing:
            case MAPErrorCode.unidentifiedSubscriber:
            case MAPErrorCode.illegalSubscriber:
            case MAPErrorCode.illegalEquipment:
            case MAPErrorCode.teleserviceNotProvisioned:
            case MAPErrorCode.messageWaitingListFull:
            case MAPErrorCode.unauthorizedRequestingNetwork:
            case MAPErrorCode.resourceLimitation:
            case MAPErrorCode.unknownOrUnreachableLCSClient:
            case MAPErrorCode.incompatibleTerminal:
            case MAPErrorCode.noRoamingNumberAvailable:
            case MAPErrorCode.noSubscriberReply:
            case MAPErrorCode.forwardingFailed:
            case MAPErrorCode.orNotAllowed:
            case MAPErrorCode.forwardingViolation:
            case MAPErrorCode.numberChanged:
            case MAPErrorCode.unknownMSC:
            case MAPErrorCode.unknownEquipment:
            case MAPErrorCode.bearerServiceNotProvisioned:
            case MAPErrorCode.mmEventNotSupported:
            case MAPErrorCode.illegalSSOperation:
            case MAPErrorCode.ssNotAvailable:
            case MAPErrorCode.ssSubscriptionViolation:
            case MAPErrorCode.unknownAlphabet:
            case MAPErrorCode.ussdBusy:
            case MAPErrorCode.negativePWCheck:
            case MAPErrorCode.numberOfPWAttemptsViolation:
            case MAPErrorCode.shortTermDenial:
            case MAPErrorCode.longTermDenial:
                return new MAPErrorMessageExtensionContainerImpl(errorCode);

            case MAPErrorCode.smDeliveryFailure:
                return new MAPErrorMessageSMDeliveryFailureImpl();

            case MAPErrorCode.absentSubscriberSM:
                return new MAPErrorMessageAbsentSubscriberSMImpl();

            case MAPErrorCode.systemFailure:
                return new MAPErrorMessageSystemFailureImpl();

            case MAPErrorCode.callBarred:
                return new MAPErrorMessageCallBarredImpl();

            case MAPErrorCode.facilityNotSupported:
                return new MAPErrorMessageFacilityNotSupImpl();

            case MAPErrorCode.unknownSubscriber:
                return new MAPErrorMessageUnknownSubscriberImpl();

            case MAPErrorCode.subscriberBusyForMTSMS:
                return new MAPErrorMessageSubscriberBusyForMtSmsImpl();

            case MAPErrorCode.absentSubscriber:
                return new MAPErrorMessageAbsentSubscriberImpl();

            case MAPErrorCode.unauthorizedLCSClient:
                return new MAPErrorMessageUnauthorizedLCSClientImpl();

            case MAPErrorCode.positionMethodFailure:
                return new MAPErrorMessagePositionMethodFailureImpl();

            case MAPErrorCode.busySubscriber:
                return new MAPErrorMessageBusySubscriberImpl();

            case MAPErrorCode.cugReject:
                return new MAPErrorMessageCUGRejectImpl();

            case MAPErrorCode.roamingNotAllowed:
                return new MAPErrorMessageRoamingNotAllowedImpl();

            case MAPErrorCode.ssErrorStatus:
                return new MAPErrorMessageSsErrorStatusImpl();

            case MAPErrorCode.ssIncompatibility:
                return new MAPErrorMessageSsIncompatibilityImpl();

            case MAPErrorCode.pwRegistrationFailure:
                return new MAPErrorMessagePwRegistrationFailureImpl();

            default:
                return new MAPErrorMessageParameterlessImpl(errorCode);
        }

    }
315479
def error_code(self, code):
		

		context = {
			'error_title': "Damn error page %i" % code,
			'error_header': "What has happened?",
			'error_footer': "WHY!?!?!",
			'error_messages': {
				('Error %i' % code): self.__message__(code)
			}
		}
		return WWebTemplateResponse(WTemplateText(self.__error_template__()), context=context)
101363
protected void validateDate(String field, String min, String max, String errorKey, String errorMessage) {
		// validateDate(field, Date.valueOf(min), Date.valueOf(max), errorKey, errorMessage);  为了兼容 64位 JDK
		try {
			SimpleDateFormat sdf = new SimpleDateFormat(getDatePattern());
			validateDate(field, sdf.parse(min.trim()), sdf.parse(max.trim()), errorKey, errorMessage);
		} catch (Exception e) {
			addError(errorKey, errorMessage);
		}
	}
406478
public String castToPrintableMessage(long number) {
        long i = number / 1048576;
        if (i > 0)
            return String.valueOf(i) + " MB";

        else {
            long l = number / 1024;
            return String.valueOf(l) + " KB";
        }

    }
501326
public BaseResponse delTemplate(String templateId) {
        LOG.debug("删除模板......");
        BeanUtil.requireNonNull(templateId, "templateId is null");
        String url = BASE_API_URL + "cgi-bin/template/del_private_template?access_token=#";
        Map<String, String> map = new HashMap<String, String>();
        map.put("template_id", templateId);
        BaseResponse r = executePost(url, JSONUtil.toJson(map));
        String resultJson = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString();
        return JSONUtil.toBean(resultJson, BaseResponse.class);
    }