小程序获取access_token


<?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}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM