小程序獲取access_token
阿新 • • 發佈:2018-12-03
acc apps aca .com json數據 cde 小時 數據 div
<?php //小程序appid $appid = ‘wx79d7c348d19f010c‘; //小程序 APPSecret 密鑰 $appsecret = ‘d624aca86d0350eec824cde1baec36cb‘; $url = ‘https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=‘ . $appid . ‘&secret=‘ . $appsecret; $token_json = file_get_contents($url); //可以將轉換的數組保存到數據庫中,token有效時長2小時內不用重新獲取了$token_arr = json_decode($token_json,true); echo $token_json;exit; //返回json數據例: //{"access_token":"16_i3UvTXusBfyAfRBDWF2jGws9fyuPoWr5ZZXoc91wjoZAutkGC9b5wKkpPal-B5tBu3Jhd0oMJ3hCqJhigPtUo1SKikolPH6-jFFIMkb2U7A0TMU8sp04hm_F2gSV_txj50oOgZ-OXfiho-2SKMQeAHAFHL","expires_in":7200}
小程序獲取access_token