Home >Backend Development >PHP Tutorial >微信开发,老是获取token失败
微信开发,总是获取token失败
<br /><br />$appid = 'wx1aabc8673b8f103a';<br />$appsecret = '9aa99fc9db9bf1321c1afe05feb29b6c';<br />$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret";<br />$url='https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx1aabc8673b8f103a&secret=9aa99fc9db9bf1321c1afe05feb29b6c';<br /><br /><br />//echo $access_token;<br /><br />function getDo($url){<br />$ch = curl_init();<br />curl_setopt($ch, CURLOPT_URL, $url);<br />curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); <br />curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); <br />curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br />$output = curl_exec($ch);<br />curl_close($ch);<br />$jsoninfo = json_decode($output, true);<br /><br />return $jsoninfo;<br />}<br /><br />$arr=getDo($url);<br /><br /><br />$info_url = "https://api.weixin.qq.com/sns/userinfo?access_token={$arr["access_token"]}&openid={$appid}&lang=zh_CN";<br /><br /><br /><br /> print_r(getDo($info_url));<br />