Now you need to do a WeChat public platform to connect to the database development, have no idea, you look at the PHP example give a train of thought, whether can be realized,
The following is the PHP code:
<? PHP
/* *
* wechat PHP test
*/
//define your token
Define (" TOKEN ", "weixin");
$wechatObj=new wechatCallbackapiTest ();
$wechatObj - & gt; Valid ();
The class wechatCallbackapiTest
{
The public function valid ()
{
$echoStr=$_GET [" echoStr "];
//valid signature, option
If ($this - & gt; CheckSignature ()) {
Echo $echoStr;
exit;
}
}
The public function responseMsg ()
{
//get the post data, May be due to the company's environments
$postStr=$GLOBALS [" HTTP_RAW_POST_DATA "];
//extract post data
if (! Empty ($postStr)) {
$postObj=simplexml_load_string ($postStr, 'simplexmlelements, LIBXML_NOCDATA);
$fromUsername=$postObj - & gt; FromUserName;
$toUsername=$postObj - & gt; ToUserName;
$keyword=trim ($postObj - & gt; The Content);
$time=time();
$textTpl="& lt; Xml>
";
if(! Empty ($keyword))
{
$msgType="text";
$contentStr="Welcome to wechat world!" ;
$resultStr=sprintf ($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
Echo $resultStr;
} else {
Echo "Input something... ";
}
} else {
Echo "";
exit;
}
}
Private function checkSignature ()
{
$signature=$_GET [" signature "];
$timestamp=$_GET [" timestamp "];
$nonce=$_GET [" nonce "];
$token=token;
$tmpArr=array($token, $timestamp, $nonce);
Sort ($tmpArr);
$tmpStr=the implode ($tmpArr);
$tmpStr=sha1 ($tmpStr);
If ($tmpStr==$signature) {
return true;
} else {
return false;
}
}
}
?>
I try to use IdHTTPServer control that can parse the POST data, no ideas behind, give a way of thinking that ace!
Thank you very much!
CodePudding user response:
Directly in PHP version, more convenientCodePudding user response:
Yeah, why not use PHPCodePudding user response:
IdHTTPServer?General is the use of IdHTTPclient all send process simulation
CodePudding user response:
The building Lord, Delphi WeChat interface problem solved? I also need to this knowledge, give advice or comments please, thank youCodePudding user response:
With q...CodePudding user response:
WeChat interfaces are walking the HTTP protocol, has nothing to do with programming language, is nothing more than various HTTP requests,CodePudding user response: