We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
微信官方文档 - 接入指南 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421135319
配合 微信公众平台 - 测试号 以下都在测试号中测试通过。
配合 微信公众平台 - 测试号
以下都在测试号中测试通过。
按照文档教材基本没什么问题。
frp
80 / 443
一个接受微信请求的实体类,控制层,签名认证类。
SignatureToken.java
import lombok.Data; import lombok.experimental.Accessors; /** * @author techial */ @Data @Accessors(chain = true) public class SignatureToken { private String signature; private String timestamp; private String nonce; private String echostr; }
SignatureController.java
import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import top.techial.wechatpush.request.SignatureToken; import top.techial.wechatpush.utils.SignatureUtils; import java.util.Arrays; /** * @author techial */ @RestController @RequestMapping("/signature") @Slf4j public class SignatureController { private static final String TOKEN = "wtf-wechat"; @GetMapping public String verify(SignatureToken signatureToken) { log.info(signatureToken.toString()); String[] strings = new String[]{TOKEN, signatureToken.getTimestamp(), signatureToken.getNonce()}; Arrays.sort(strings); String sortStr = String.join("", strings); String encodeStr = SignatureUtils.encode(sortStr); if (signatureToken.getSignature().equals(encodeStr)) { return signatureToken.getEchostr(); } return null; } @PostMapping public void findAll(@RequestBody String str) { log.info(str); } }
SignatureUtils.java
import lombok.SneakyThrows; import java.security.MessageDigest; /** * @author techial */ public class SignatureUtils { private SignatureUtils() { throw new IllegalStateException("Utility class"); } private static String byteArrayToHexString(byte[] b) { StringBuilder result = new StringBuilder(); for (byte value : b) { result.append(Integer.toString((value & 0xff) + 0x100, 16).substring(1)); } return result.toString(); } @SneakyThrows public static String encode(String str) { MessageDigest messageDigest = MessageDigest.getInstance("SHA1"); messageDigest.update(str.getBytes()); return byteArrayToHexString(messageDigest.digest()); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
微信官方文档 - 接入指南 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421135319
按照文档教材基本没什么问题。
frp
等工具,将本地端口代理到公网的服务器的80 / 443
端口,不能使用使用其他端口,不然收不到请求。检验signature的 Spring Boot 示例代码
一个接受微信请求的实体类,控制层,签名认证类。
SignatureToken.java
SignatureController.java
SignatureUtils.java
The text was updated successfully, but these errors were encountered: