如下是分享的代碼集合,直接修改token,並把代碼放到服務器對接微信的url的index.php下就能夠用使用了,簡單輕鬆。php
<?php api
define("TOKEN", "weixin"); 服務器
$wechatObj = new wechatCallbackapiTest(); 微信
//沒有獲得echostr 先驗證 ui
if (!isset($_GET['echostr'])) { this
$wechatObj->responseMsg(); //處理消息 url
}else{ spa
$wechatObj->valid(); code
} token
/*$code = $_GET["code"];
$userinfo = getopenidtoken($code);
$StrOpenid=$userinfo["openid"];
*/
class wechatCallbackapiTest
{
//驗證消息
public function valid()
{
$echoStr = $_GET["echostr"];
if($this->checkSignature()){
echo $echoStr;
exit;
}
}
完整代碼能夠關注微信號,發送 ‘微信代碼’ 得到完整代碼:
輕輕關注,將推「心」的不錯經驗和知識,也有一些羣友的心得分享哦!