$appid = $_GET[‘appid’];
$secret = $_GET[‘secret’];
$js_code = $_GET[‘js_code’];
$url = ‘https://api.weixin.qq.com/sns/jscode2session’;
$data = array
(
‘appid’ => $appid, //用户账号
‘secret’ => $secret, //MD5位32密码,密码和用户名拼接字符
‘js_code’ => $js_code, //号码,以英文逗号隔开
‘grant_type’ => ‘authorization_code’, //内容
);
$ret = httpRequest($url, ‘POST’, $data);
$obj = json_decode($ret);
exit(json_encode(array(‘openid’ => $obj->openid,“sessionKey”=>$obj->session_key, ‘msg’ => ‘成功’)));