Because the ERP system needs to have a data interface with the WeChat official account, we are now preparing to build an intermediate server.
Development environment: Tracking revealed that the server was unable to receive the GET request from WeChat. The code is as follows:
Delphi/Pascal code?
interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, IdBaseComponent, IdComponent, IdCustomTCPServer, IdCustomHTTPServer, IdHTTPServer, IdContext, IdHashSHA, IdGlobal; type TForm1 = class(TForm) IdHTTPServer1: TIdHTTPServer; Button1: TButton; Memo1: TMemo; procedure Button1Click(Sender: TObject); procedure IdHTTPServer1CommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); private { Private declarations } public { Public declarations } function SHA1(Input: String): String; function CheckSignature(ARequestInfo: TIdHTTPRequestInfo): boolean; end; var Form1: TForm1; Const Token = 'weixin'; implementation {$R *.dfm} function TForm1.SHA1(Input: String): String; begin with TIdHashSHA1.Create do try Result := LowerCase(HashBytesAsHex(TidBytes(Bytesof(Input)))); finally Free; end; end; function TForm1.CheckSignature(ARequestInfo: TIdHTTPRequestInfo): boolean; var signature, timestamp, nonce, echostr: String; tmpstr: TStringList; temp: String; begin tmpstr := TStringList.Create; try signature := ARequestInfo.Params.Values['signature']; timestamp := ARequestInfo.Params.Values['timestamp']; nonce := ARequestInfo.Params.Values['nonce']; echostr := ARequestInfo.Params.Values['echostr']; tmpstr.Add(Token); tmpstr.Add(timestamp); tmpstr.Add(nonce); tmpstr.Sort; temp := StringReplace(tmpstr.text, #13#10, '', [rfReplaceAll]); Result := SHA1(temp) = signature; finally tmpstr.Free; end; end; procedure TForm1.Button1Click(Sender: TObject); begin IdHTTPServer1.Active := True; end; procedure TForm1.IdHTTPServer1CommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); begin Memo1.Lines.Add('123'); if CheckSignature(ARequestInfo) then if ARequestInfo.Params.Values['echostr'] <> '' then begin Memo1.Lines.Add(ARequestInfo.Params.Values['echostr']); AResponseInfo.ContentType := 'text/html; charset=UTF-8'; AResponseInfo.ContentText := ARequestInfo.Params.Values['echostr']; end; end; end.
The above is the detailed content of Example tutorial for developing WeChat server interface. For more information, please follow other related articles on the PHP Chinese website!

一、安装nginx容器为了让nginx支持文件上传,需要下载并运行带有nginx-upload-module模块的容器:sudopodmanpulldocker.io/dimka2014/nginx-upload-with-progress-modules:latestsudopodman-d--namenginx-p83:80docker.io/dimka2014/nginx-upload-with-progress-modules该容器同时带有nginx-upload-module模块和ng

1,将java项目打成jar包这里我用到的是maven工具这里有两个项目,打包完成后一个为demo.jar,另一个为jst.jar2.准备工具1.服务器2.域名(注:经过备案)3.xshell用于连接服务器4.winscp(注:视图工具,用于传输jar)3.将jar包传入服务器直接拖动即可3.使用xshell运行jar包注:(服务器的java环境以及maven环境,各位请自行配置,这里不做描述。)cd到jar包路径下执行:nohupjava-jardemo.jar>temp.txt&

vue3项目打包发布到服务器后访问页面显示空白1、处理vue.config.js文件中的publicPath处理如下:const{defineConfig}=require('@vue/cli-service')module.exports=defineConfig({publicPath:process.env.NODE_ENV==='production'?'./':'/&

scp是securecopy的简写,是linux系统下基于ssh登陆进行安全的远程文件拷贝命令。scp是加密的,rcp是不加密的,scp是rcp的加强版。因为scp传输是加密的,可能会稍微影响一下速度。另外,scp还非常不占资源,不会提高多少系统负荷,在这一点上,rsync就远远不及它了。虽然rsync比scp会快一点,但当小文件众多的情况下,rsync会导致硬盘I/O非常高,而scp基本不影响系统正常使用。场景:假设我现在有两台服务器(这里的公网ip和内网ip相互传都可以,当然用内网ip相互传

psutil是一个跨平台的Python库,它允许你获取有关系统进程和系统资源使用情况的信息。它支持Windows、Linux、OSX、FreeBSD、OpenBSD和NetBSD等操作系统,并提供了一些非常有用的功能,如:获取系统CPU使用率、内存使用率、磁盘使用率等信息。获取进程列表、进程状态、进程CPU使用率、进程内存使用率、进程IO信息等。杀死进程、发送信号给进程、挂起进程、恢复进程等操作。使用psutil,可以很方便地监控系统的运行状况,诊断问题和优化性能。以下是一个简单的示例,演示如何

随着深度强化学习技术的快速发展,越来越多的研究团队开始将其应用于自动驾驶决策规划中,将行为决策与运动规划模块相融合,直接学习得到行驶轨迹。 自动驾驶中的决策规划模块是衡量和评价自动驾驶能力最核心的指标之一,它的主要任务是在接收到传感器的各种感知信息之后,对当前环境作出分析,然后对底层控制模块下达指令。典型的决策规划模块可以分为三个层次:全局路径规划、行为决策、运动规划。01 引言在一套完整的自动驾驶系统中,如果将感知模块比作人的眼睛和耳朵,那么决策规划就是自动驾驶的大脑。大脑在接收到传感器的各种

StreamHandler和FileHandler首先我们先来写一套简单输出到cmd和文件中的代码:#-*-coding:utf-8-*-"""-------------------------------------------------FileName:logerDescription:Author:yangyanxingdate:2020/9/23-------------------------------------------------"&

服务器指的是网络环境下能为其它客户机(如PC机、智能手机、ATM等终端甚至是火车系统等大型设备)提供某种服务的专用计算机,它比普通计算机运行更快、负载更高、价格更贵。服务器具有高速的CPU运算能力、长时间的可靠运行、强大的I/O外部数据吞吐能力以及更好的扩展性。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1
Easy-to-use and free code editor
