第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

token驗證失敗,一模一樣的東西

為什么代碼一模一樣還是不能通過開發(fā)者模式驗證,顯示:TOKEN驗證失敗!

幾天都沒看出來有什么問題,求解答,

//WeixinServlet.java文件

package servlet;


import java.io.IOException;

import java.io.PrintWriter;


import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;


import toolsClass.CheckUtil;


public class WeixinServlet extends HttpServlet {


/**

* Constructor of the object.

*/

public WeixinServlet() {

super();

}


public void destroy() {

super.destroy(); // Just puts "destroy" string in log

// Put your code here

}


public void doDelete(HttpServletRequest request,

HttpServletResponse response) throws ServletException, IOException {


// Put your code here

}


public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {


String signature = request.getParameter("signature");

String timestamp = request.getParameter("timestamp");

String nonce = request.getParameter("nonce");

String echostr = request.getParameter("echostr");

//返回隨機字符串:echostr

PrintWriter out = response.getWriter();

if(CheckUtil.checkSignature(signature,timestamp,nonce)){

//

System.out.println("微信服務(wù)器身份驗證通過");

out.print(echostr);

}

}


public void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {


response.setContentType("text/html");

PrintWriter out = response.getWriter();

out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");

out.println("<HTML>");

out.println(" ?<HEAD><TITLE>A Servlet</TITLE></HEAD>");

out.println(" ?<BODY>");

out.print(" ? ?This is ");

out.print(this.getClass());

out.println(", using the POST method");

out.println(" ?</BODY>");

out.println("</HTML>");

out.flush();

out.close();

}


public void doPut(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {


// Put your code here

}


public void init() throws ServletException {

// Put your code here

}


}

//CheckUtil.java文件

package toolsClass;


import java.security.MessageDigest;

import java.util.Arrays;


public class CheckUtil {

private static final String token = "Walter";

public static boolean checkSignature(String signature,String timestamp,String nonce){

String []arr = new String[]{token,timestamp,nonce};

//排序

Arrays.sort(arr);

//生成字符串

StringBuffer content = new StringBuffer();

for (int i=0;i<arr.length;i++ ){

content.append(arr[i]); //append方法用來累積字符串的,?

}


//sha1加密

String temp = getSha1(content.toString());

return temp.equals(signature);


}

//sha1加密算法

static String ?getSha1(String str){

if(str == null || str.length()==0)

return null;

char hexDigits[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};

try{

MessageDigest mdTemp = MessageDigest.getInstance("SHA2");

mdTemp.update(str.getBytes("UTF-8"));

byte[] md = mdTemp.digest();

int j = md.length;

char buf[] = new char[j*2];

int k = 0;

for(int i=0;i<j;i++){

byte byte0 = md[i];

buf[k++] = hexDigits[byte0>>>4 & 0xf];

buf[k++] = hexDigits[byte0 & 0xf];

}

return new String(buf);

}catch(Exception e){

return null;

}

}

public static void main(String []argss){

System.out.println("===========SHA2:是SHA1算法。");

?

}

}

56c7f3e500010aa105000212.jpg

56c7f3e500014e5005000287.jpg


正在回答

3 回答

我也是同樣問題你解決了沒有


0 回復(fù) 有任何疑惑可以回復(fù)我~

問題不在代碼,每次使用ngrok你都要在命令環(huán)境里運行那條命令然后映射成功的那個界面不要關(guān)掉就可以提交成功了,前提是你的代碼確實沒有問題

0 回復(fù) 有任何疑惑可以回復(fù)我~

是不是沒有設(shè)置權(quán)限啊.

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
初識Java微信公眾號開發(fā)
  • 參與學(xué)習(xí)       158313    人
  • 解答問題       684    個

Java微信公眾號開發(fā)的入門教程,掌握微信公眾號基本概念

進入課程

token驗證失敗,一模一樣的東西

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號