¿Dónde están los ejemplos de Java de Microsoft?
cadena final estática privada TOKEN = "xxxxxx";
índice vacío público() {
firma de cadena = getPara("firma ");
String marca de tiempo = getPara("marca de tiempo");
String nonce = getPara("nonce");
String echostr = getPara(" echostr");
if(null ! = marca de tiempo; amp; null ! = nonce amp; amp; null ! = echostr; amp; null ! = firma) {
if( WeiXin.access(TOKEN, firma, marca de tiempo, nonce)) {
renderHtml(ehostr
return
}
renderNull();
retorno
}
prueba {
WxRecvMsg msg = WeiXin.recv(getRequest().getInputStream( ));
WxSendMsg sendMsg = WeiXin.builderSendByRecv(msg);
System.out.println(msg);
if(msg instancia de WxRecvEventMsg) {
WxRecvEventMsg m = (WxRecvEventMsg) msg;
String event = m.getEvent()
if("subscribe".equals(event)) {
String content = "Gracias por su atención";
sendMsg = new WxSendTextMsg(sendMsg, content);
WeiXin.send(sendMsg, getResponse( ).getOutputStream());
renderNull()
}
}
if(msg instancia de WxRecvTextMsg) { p>
WxRecvTextMsg m = (WxRecvTextMsg) msg;
Texto de cadena = m.getContent()
if( null ! = texto)
texto = text.trim();
Stringgt; claveworkds = new HashSetlt ();
s.add("1");
keyworkds.add("menú");
keyworkds.add("menú");
if( keyworkds.contains(text)) {
String content = "1. menu\n2.graphic\n";
sendMsg = new WxSendTextMsg(sendMsg, content);
} else if("2".equals(texto)) {
sendMsg = new WxSendMusicMsg(sendMsg, "Noche Noche Noche", "Lin",
" /-fo3dSag_xI4khGko9WTAnF6hhy/album/w=230/sign=b2b8791418d8bc3ec60801c9b28ba6c8/ 1ad5ad6eddc451da5ff2c0c5b7fd5266d016329c.jpg","/94o3dSag_xI4khGko 9WTA nF6hhy/album/w=230/sign=67afac3d242dd42a5f0906a8333a5b2f/ 8c1001e93901213f088bb78855e736d12f2e952e.jpg", "")
. addItem ("Imagen 2", "Descripción 2", "/-4o3dSag_xI4khGko9WTAnF6hhy/album/w=230/sign=5254e9265243fbf2c52ca120807eca1e/77c6a7efce1b9d1669f2564ff2deb48f8c5464e3.jpg ","")
.addItem("Imagen 3", " Descripción 3", "/-Po3dSag_ xI4khGko9WTAnF6hhy/album/w=230/sign=c3b3fe3aaa18972ba33a07c9d6cc7b9d/3812b31bb051f81995bdc164dbb44aed2e73e700.jpg", "")
; >
más {
Contenido de cadena = "1. menú\n2. música\n, 3. gráfico\n"
sendMsg = new WxSendTextMsg(sendMsg, content
}< / p>
WeiXin.send( sendMsg, getResponse().getOutputStream());
renderNull()
return
} else; {
String content = "1. menú\n2. música\n, 3. gráfico\n"
sendMsg = new WxSendTextMsg(sendMsg, content
);WeiXin.send(sendMsg, getResponse().getOutputStream()
renderNull();
retorno;
}
} captura (JDOMException e) {
e.printStackTrace(); > } captura (IOException e) {
e. printStackTrace();
}
renderNull(); p>
}
}