1.在开始之前我们首先要有一个域名(www.wyzdjg.top)和公众号(这里是订阅号)。
2.我们首先在服务器建立一个weixin文件夹,里面有一个index.php文件,如下图:
然后我们在index.php文件中写入以下代码,然后上传:
valid();
class wechatCallbackapiTest
{
public function valid()
{
$echoStr = $_GET["echostr"];
//valid signature , option
if($this->checkSignature()){
echo $echoStr;
exit;
}
}
public function responseMsg()
{
//get post data, May be due to the different environments
$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
//extract post data
if (!empty($postStr)){
$postObj = simplexml_load_string($post