微信获得access_token

时间:2015-05-07 14:02:49   收藏:0   阅读:227
<?php
//获取access_token
$appid = ‘wx47a6fc3c1187e60d‘; //测试账号appid
$appsecret = ‘525f76d57c7bd72005865e05d03e9dbe‘; //测试账号

$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret";
$json = file_get_contents($url); 
$re = json_decode($json,true);
$access_token = $re[‘access_token‘];  
//使用全局ACCESS_TOKEN获取OpenID的详细信息
//$openid = ‘ohzcAsy35rFHUcabQkAXPmv2FC00‘;
// $openid = $_GET[‘openid‘];
// $url = ‘https://api.weixin.qq.com/cgi-bin/user/info?access_token=‘.$access_token.‘&openid=‘.$openid;
// $json = file_get_contents($url);
// $arr = json_decode($json,true);
// $name = $arr[‘nickname‘];
// $imgURL = $arr[‘headimgurl‘];
// $sex = $arr[‘sex‘];
// $province = $arr[‘province‘];
// $city= $arr[‘city‘];
// $country= $arr[‘country‘];
// var_dump($arr);
?>


来自为知笔记(Wiz)


评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!