index.php
<?
//scope=snsapi_base 实例
$appid='appid';
$redirect_uri = urlencode('http://wx.xswkj.com/getUserInfo.php');
$url ="https://open.weixin.qq.com/connect/oauth2/authorize?appid=$appid&redirect_uri=$redirect_uri&response_type=code&scope=snsapi_base&state=1#wechat_redirect";
header("Location:".$url);
?>
getinfo.php
<?
header("Content-type: text/html; charset=utf-8");
//ID 密钥
$appid = "appid";
$appsecret = "appsecret";
$code = $_GET["code"];
//第一步:取全局access_token
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret";
//$token = getJson($url);
$jsoninfo = https_request($url);
//$jsoninfo = json_decode($output,