Commit a364501c by biao

1

parent 66844815
...@@ -49,8 +49,8 @@ define("SMS_APP_KEY", "3c6208374d1940652303ae08396ce5f8"); //密码 ...@@ -49,8 +49,8 @@ define("SMS_APP_KEY", "3c6208374d1940652303ae08396ce5f8"); //密码
// 微信认证相关【公众号】 // 微信认证相关【公众号】
define("WECHAT_APP_ID","wxe16f5f4f71862e9f"); define("WECHAT_APP_ID","wxeef50c5d0ef117d1");
define("WECHAT_APP_SECRET","138738e444eab87a39cf2ed33886da5d"); define("WECHAT_APP_SECRET","48dd0dfd509d1438aa4950d7dcdbee9e");
define("WECHAT_AUTH_TOKEN","COMPASS"); define("WECHAT_AUTH_TOKEN","COMPASS");
define("WECHAT_PAY_MCHID","1371137902"); define("WECHAT_PAY_MCHID","1371137902");
define("WECHAT_PAY_KEY","a1b2c3defghijKlmnopqrstuvwx4y5z6"); define("WECHAT_PAY_KEY","a1b2c3defghijKlmnopqrstuvwx4y5z6");
......
...@@ -6,21 +6,23 @@ require_once ("../user_include.inc"); ...@@ -6,21 +6,23 @@ require_once ("../user_include.inc");
ErrorLogger::doOutput("Compass...ajax_check_user_registed.php....Start.", 0); ErrorLogger::doOutput("Compass...ajax_check_user_registed.php....Start.", 0);
//根据常量获取定义的值 //根据常量获取定义的值
$jsCode = ParamUtil::getRequestString("code", ""); $jsCode = ParamUtil::getRequestString("code");
$openId = ParamUtil::getRequestString("openId", ""); $openId = ParamUtil::getRequestString("openId");
ErrorLogger::doOutput("Compass...ajax_check_user_registed.php....code=" . $jsCode, 0); ErrorLogger::doOutput("Compass...ajax_check_user_registed.php....jsCode=" . $jsCode, 0);
ErrorLogger::doOutput("Compass...ajax_check_user_registed.php....openId=" . $openId, 0); ErrorLogger::doOutput("Compass...ajax_check_user_registed.php....openId=" . $openId, 0);
$result = array(); $result = array();
//如果都为空说明调用错误 //如果都为空说明调用错误
if(empty($code) && empty($openId)) { if(empty($jsCode) && empty($openId)) {
ErrorLogger::doOutput("Compass...ajax_check_user_registed.php....1", 0);
$result["message"] = "参数错误!"; $result["message"] = "参数错误!";
responseNG($result); responseNG($result);
} }
//有openId的情况下 //有openId的情况下
if(!empty($openId)) { if(!empty($openId)) {
ErrorLogger::doOutput("Compass...ajax_check_user_registed.php....2", 0);
//检索数据库 //检索数据库
$param['openid'] = $openId; $param['openid'] = $openId;
$param['delete_flg'] = false; $param['delete_flg'] = false;
...@@ -35,18 +37,22 @@ if(!empty($openId)) { ...@@ -35,18 +37,22 @@ if(!empty($openId)) {
} }
//有code的情况下 //有code的情况下
if(!empty($js_code)) { if(!empty($jsCode)) {
ErrorLogger::doOutput("Compass...ajax_check_user_registed.php....3", 0);
$appId = WECHAT_APP_ID; $appId = WECHAT_APP_ID;
$appSecret = WECHAT_APP_SECRET; $appSecret = WECHAT_APP_SECRET;
//调用微信接口获取用户的openId和unionId //调用微信接口获取用户的openId和unionId
//调用服务器查询并插入数据 //调用服务器查询并插入数据
$ch = curl_init(); $ch = curl_init();
$url = "https://api.weixin.qq.com/sns/jscode2session?appid=" . $appId . "&secret=" . $appSecret . "&js_code=" . $jsCode . "&grant_type=authorization_code"; $url = "https://api.weixin.qq.com/sns/jscode2session?appid=" . $appId . "&secret=" . $appSecret . "&js_code=" . $jsCode . "&grant_type=authorization_code";
ErrorLogger::doOutput("Compass...ajax_check_user_registed.php....url=" . $url, 0);
//通过code换取网页授权access_token //通过code换取网页授权access_token
$weixin = file_get_contents($url); $weixin = file_get_contents($url);
$weixinJson = json_decode($weixin); //对JSON格式的字符串进行编码 $json = json_decode($weixin); //对JSON格式的字符串进行编码
$weixinArray = get_object_vars($weixinJson);//转换成数组 $wxArray = get_object_vars($json);//转换成数组
$openId = $weixinArray["openid"]; $openId = $wxArray["openid"];
$unionId = $wxArray["unionid"];
ErrorLogger::doOutput("Compass...ajax_check_user_registed.php....wxArray=" . print_r($wxArray, 1), 0);
if(!empty($openId)) { if(!empty($openId)) {
//检索数据库 //检索数据库
$param['openid'] = $openId; $param['openid'] = $openId;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment