HTML微信Token代碼
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>微信Token獲取頁面</title> </head> <body> <h1>微信Token獲取頁面</h1> <p>請?jiān)谙旅孑斎肽腁ppId和AppSecret,點(diǎn)擊獲取Token按鈕即可生成微信Token。</p> <form action="#" method="POST"> <p> <label for="appid">AppId:</label> <input id="appid" type="text" name="appid" required> </p> <p> <label for="appsecret">AppSecret:</label> <input id="appsecret" type="password" name="appsecret" required> </p> <p> <input type="submit" value="獲取Token"> </p> </form> <?php if(isset($_POST['appid']) && isset($_POST['appsecret'])){ $appid=$_POST['appid']; $appsecret=$_POST['appsecret']; $url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$appsecret; $result=file_get_contents($url); $json=json_decode($result); if(isset($json->access_token)){ echo "<p>您的微信Token為:</p>"; echo "<pre>".$json->access_token."</pre>"; }else{ echo "<p>獲取微信Token失敗,請檢查AppId和AppSecret是否正確。</p>"; } } ?> </body> </html>