{"id":30067,"date":"2024-11-25T08:01:43","date_gmt":"2024-11-25T00:01:43","guid":{"rendered":"https:\/\/fwq.ai\/blog\/30067\/"},"modified":"2024-11-25T08:01:43","modified_gmt":"2024-11-25T00:01:43","slug":"%e5%bc%80%e5%8f%91%e5%be%ae%e4%bf%a1%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%8e%a5%e5%8f%a3%e7%9a%84%e5%ae%9e%e4%be%8b%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/30067\/","title":{"rendered":"\u5f00\u53d1\u5fae\u4fe1\u670d\u52a1\u5668\u63a5\u53e3\u7684\u5b9e\u4f8b\u6559\u7a0b"},"content":{"rendered":"<p>\u56e0erp\u7cfb\u7edf\u9700\u8981\u4e0e\u5fae\u4fe1\u516c\u4f17\u53f7\u505a\u6570\u636e\u63a5\u53e3\uff0c\u73b0\u51c6\u5907\u505a\u4e00\u4e2a\u4e2d\u95f4\u670d\u52a1\u5668\u3002<br \/>\u5f00\u53d1\u73af\u5883\uff1axe10<br \/>\u4f7f\u7528\u63a7\u4ef6\uff1aidhttpserver<\/p>\n<p>\u56e0\u521a\u5f00\u53d1\u9636\u6bb5\uff0c\u5728\u8def\u7531\u8def\u4e0a\u76f4\u63a5\u505a\u4e86\u6d4b\u8bd5\u673a\u768480\u7aef\u53e3\u8f6c\u53d1\uff0c\u7533\u8bf7\u5fae\u4fe1\u516c\u4f17\u6d4b\u8bd5\u53f7\u540e\uff0c\u5374\u4e00\u76f4\u914d\u7f6e\u5931\u8d25\u3002\u8ddf\u8e2a\u53d1\u73b0\u662f\u670d\u52a1\u5668\u65e0\u6cd5\u6536\u5230\u5fae\u4fe1\u53d1\u6765\u7684get\u8bf7\u6c42\u3002\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>Delphi\/Pascal code?<\/p>\n<p>unit&nbsp;Unit1;<\/p>\n<pre>interface\r\n&nbsp;\r\nuses\r\n&nbsp;&nbsp;Winapi.Windows,&nbsp;Winapi.Messages,&nbsp;System.SysUtils,&nbsp;System.Variants,&nbsp;System.Classes,&nbsp;Vcl.Graphics,\r\n&nbsp;&nbsp;Vcl.Controls,&nbsp;Vcl.Forms,&nbsp;Vcl.Dialogs,&nbsp;Vcl.StdCtrls,&nbsp;IdBaseComponent,\r\n&nbsp;&nbsp;IdComponent,&nbsp;IdCustomTCPServer,&nbsp;IdCustomHTTPServer,&nbsp;IdHTTPServer,&nbsp;IdContext,\r\n&nbsp;&nbsp;IdHashSHA,&nbsp;IdGlobal;\r\n&nbsp;\r\ntype\r\n&nbsp;&nbsp;TForm1&nbsp;=&nbsp;class(TForm)\r\n&nbsp;&nbsp;&nbsp;&nbsp;IdHTTPServer1:&nbsp;TIdHTTPServer;\r\n&nbsp;&nbsp;&nbsp;&nbsp;Button1:&nbsp;TButton;\r\n&nbsp;&nbsp;&nbsp;&nbsp;Memo1:&nbsp;TMemo;\r\n&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Button1Click(Sender:&nbsp;TObject);\r\n&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;IdHTTPServer1CommandGet(AContext:&nbsp;TIdContext;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ARequestInfo:&nbsp;TIdHTTPRequestInfo;&nbsp;AResponseInfo:&nbsp;TIdHTTPResponseInfo);\r\n&nbsp;&nbsp;private\r\n&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Private&nbsp;declarations&nbsp;}\r\n&nbsp;&nbsp;public\r\n&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Public&nbsp;declarations&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;SHA1(Input:&nbsp;String):&nbsp;String;\r\n&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;CheckSignature(ARequestInfo:&nbsp;TIdHTTPRequestInfo):&nbsp;boolean;\r\n&nbsp;&nbsp;end;\r\n&nbsp;\r\nvar\r\n&nbsp;&nbsp;Form1:&nbsp;TForm1;\r\nConst\r\n&nbsp;&nbsp;Token&nbsp;=&nbsp;'weixin';\r\n&nbsp;\r\nimplementation\r\n&nbsp;\r\n{$R&nbsp;*.dfm}\r\n&nbsp;\r\nfunction&nbsp;TForm1.SHA1(Input:&nbsp;String):&nbsp;String;\r\nbegin\r\n&nbsp;&nbsp;with&nbsp;TIdHashSHA1.Create&nbsp;do\r\n&nbsp;&nbsp;try\r\n&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;LowerCase(HashBytesAsHex(TidBytes(Bytesof(Input))));\r\n&nbsp;&nbsp;finally\r\n&nbsp;&nbsp;&nbsp;&nbsp;Free;\r\n&nbsp;&nbsp;end;\r\nend;\r\n&nbsp;\r\n&nbsp;\r\nfunction&nbsp;TForm1.CheckSignature(ARequestInfo:&nbsp;TIdHTTPRequestInfo):&nbsp;boolean;\r\nvar\r\n&nbsp;&nbsp;signature,&nbsp;timestamp,&nbsp;nonce,&nbsp;echostr:&nbsp;String;\r\n&nbsp;&nbsp;tmpstr:&nbsp;TStringList;\r\n&nbsp;&nbsp;temp:&nbsp;String;\r\nbegin\r\n&nbsp;&nbsp;tmpstr&nbsp;:=&nbsp;TStringList.Create;\r\n&nbsp;&nbsp;try\r\n&nbsp;&nbsp;&nbsp;&nbsp;signature&nbsp;:=&nbsp;ARequestInfo.Params.Values['signature'];\r\n&nbsp;&nbsp;&nbsp;&nbsp;timestamp&nbsp;:=&nbsp;ARequestInfo.Params.Values['timestamp'];\r\n&nbsp;&nbsp;&nbsp;&nbsp;nonce&nbsp;:=&nbsp;ARequestInfo.Params.Values['nonce'];\r\n&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;echostr&nbsp;:=&nbsp;ARequestInfo.Params.Values['echostr'];\r\n&nbsp;&nbsp;&nbsp;&nbsp;tmpstr.Add(Token);\r\n&nbsp;&nbsp;&nbsp;&nbsp;tmpstr.Add(timestamp);\r\n&nbsp;&nbsp;&nbsp;&nbsp;tmpstr.Add(nonce);\r\n&nbsp;&nbsp;&nbsp;&nbsp;tmpstr.Sort;\r\n&nbsp;&nbsp;&nbsp;&nbsp;temp&nbsp;:=&nbsp;StringReplace(tmpstr.text,&nbsp;#13#10,&nbsp;'',&nbsp;[rfReplaceAll]);\r\n&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;SHA1(temp)&nbsp;=&nbsp;signature;\r\n&nbsp;&nbsp;finally\r\n&nbsp;&nbsp;&nbsp;&nbsp;tmpstr.Free;\r\n&nbsp;&nbsp;end;\r\nend;\r\n&nbsp;\r\n&nbsp;\r\nprocedure&nbsp;TForm1.Button1Click(Sender:&nbsp;TObject);\r\nbegin\r\n&nbsp;&nbsp;IdHTTPServer1.Active&nbsp;:=&nbsp;True;\r\nend;\r\n&nbsp;\r\nprocedure&nbsp;TForm1.IdHTTPServer1CommandGet(AContext:&nbsp;TIdContext;\r\n&nbsp;&nbsp;ARequestInfo:&nbsp;TIdHTTPRequestInfo;&nbsp;AResponseInfo:&nbsp;TIdHTTPResponseInfo);\r\nbegin\r\n&nbsp;&nbsp;Memo1.Lines.Add('123');\r\n&nbsp;&nbsp;if&nbsp;CheckSignature(ARequestInfo)&nbsp;then\r\n&nbsp;&nbsp;if&nbsp;ARequestInfo.Params.Values['echostr']&nbsp;&nbsp;''&nbsp;then\r\n&nbsp;&nbsp;begin\r\n&nbsp;&nbsp;&nbsp;&nbsp;Memo1.Lines.Add(ARequestInfo.Params.Values['echostr']);\r\n&nbsp;&nbsp;&nbsp;&nbsp;AResponseInfo.ContentType&nbsp;:=&nbsp;'text\/html;&nbsp;charset=UTF-8';\r\n&nbsp;&nbsp;&nbsp;&nbsp;AResponseInfo.ContentText&nbsp;:=&nbsp;ARequestInfo.Params.Values['echostr'];\r\n&nbsp;&nbsp;end;\r\nend;\r\n&nbsp;\r\nend.<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5f00\u53d1\u5fae\u4fe1\u670d\u52a1\u5668\u63a5\u53e3\u7684\u5b9e\u4f8b\u6559\u7a0b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u56e0erp\u7cfb\u7edf\u9700\u8981\u4e0e\u5fae\u4fe1\u516c\u4f17\u53f7\u505a\u6570\u636e\u63a5\u53e3\uff0c\u73b0\u51c6\u5907\u505a\u4e00\u4e2a\u4e2d\u95f4\u670d\u52a1\u5668\u3002\u5f00\u53d1\u73af\u5883\uff1axe10\u4f7f\u7528\u63a7\u4ef6\uff1aidhttpserver \u56e0\u521a\u5f00\u53d1\u9636\u6bb5\uff0c\u5728\u8def\u7531\u8def\u4e0a\u76f4\u63a5\u505a\u4e86\u6d4b\u8bd5\u673a\u768480\u7aef\u53e3\u8f6c\u53d1\uff0c\u7533\u8bf7\u5fae\u4fe1\u516c\u4f17\u6d4b\u8bd5\u53f7\u540e\uff0c\u5374\u4e00\u76f4\u914d\u7f6e\u5931\u8d25\u3002\u8ddf\u8e2a\u53d1\u73b0\u662f\u670d\u52a1\u5668\u65e0\u6cd5\u6536\u5230\u5fae\u4fe1\u53d1\u6765\u7684get\u8bf7\u6c42\u3002\u4ee3\u7801\u5982\u4e0b\uff1a Delphi\/Pascal code? unit&nbsp;Unit1; interface &nbsp; uses &nbsp;&nbsp;Winapi.Windows,&nbsp;Winapi.Messages,&nbsp;System.SysUtils,&nbsp;System.Variants,&nbsp;System.Classes,&nbsp;Vcl.Graphics, &nbsp;&nbsp;Vcl.Controls,&nbsp;Vcl.Forms,&nbsp;Vcl.Dialogs,&nbsp;Vcl.StdCtrls,&nbsp;IdBaseComponent, &nbsp;&nbsp;IdComponent,&nbsp;IdCustomTCPServer,&nbsp;IdCustomHTTPServer,&nbsp;IdHTTPServer,&nbsp;IdContext, &nbsp;&nbsp;IdHashSHA,&nbsp;IdGlobal; &nbsp; type &nbsp;&nbsp;TForm1&nbsp;=&nbsp;class(TForm) &nbsp;&nbsp;&nbsp;&nbsp;IdHTTPServer1:&nbsp;TIdHTTPServer; &nbsp;&nbsp;&nbsp;&nbsp;Button1:&nbsp;TButton; &nbsp;&nbsp;&nbsp;&nbsp;Memo1:&nbsp;TMemo; &nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Button1Click(Sender:&nbsp;TObject); &nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;IdHTTPServer1CommandGet(AContext:&nbsp;TIdContext; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ARequestInfo:&nbsp;TIdHTTPRequestInfo;&nbsp;AResponseInfo:&nbsp;TIdHTTPResponseInfo); &nbsp;&nbsp;private &nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Private&nbsp;declarations&nbsp;} &nbsp;&nbsp;public &nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Public&nbsp;declarations&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;SHA1(Input:&nbsp;String):&nbsp;String; &nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;CheckSignature(ARequestInfo:&nbsp;TIdHTTPRequestInfo):&nbsp;boolean; &nbsp;&nbsp;end; &nbsp; var &nbsp;&nbsp;Form1:&nbsp;TForm1; Const &nbsp;&nbsp;Token&nbsp;=&nbsp;&#8216;weixin&#8217;; &nbsp; implementation &nbsp; {$R&nbsp;*.dfm} &nbsp; function&nbsp;TForm1.SHA1(Input:&nbsp;String):&nbsp;String; begin &nbsp;&nbsp;with&nbsp;TIdHashSHA1.Create&nbsp;do &nbsp;&nbsp;try &nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;LowerCase(HashBytesAsHex(TidBytes(Bytesof(Input)))); &nbsp;&nbsp;finally &nbsp;&nbsp;&nbsp;&nbsp;Free; &nbsp;&nbsp;end; end; &nbsp; &nbsp; function&nbsp;TForm1.CheckSignature(ARequestInfo:&nbsp;TIdHTTPRequestInfo):&nbsp;boolean; var &nbsp;&nbsp;signature,&nbsp;timestamp,&nbsp;nonce,&nbsp;echostr:&nbsp;String; &nbsp;&nbsp;tmpstr:&nbsp;TStringList; &nbsp;&nbsp;temp:&nbsp;String; begin [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-30067","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30067","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=30067"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30067\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=30067"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=30067"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=30067"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}