123456789101112131415161718192021222324252627282930313233 |
- <?php
- defined('ONLY_ONLY_ONLY') or exit('Access Denied');
- define('LOG_CATALOG',"KLY_OAuthCode");
- try{
- require_once WEB_PHY_ROOT."/base/wxsrv.php";
- weixin_oauthCallBack(LOG_CATALOG,function($appid,$state){
- if(!empty($state)){//可按业务类别进行特殊处理
- $stateInfo=explode(":",$state);
- if(count($stateInfo)==2){
- $bizCatalog=$stateInfo[0];
- $bizId=$stateInfo[1];
- }
- }
- //if($appid!=WeiXin111_AppID) throw new GeneralException("","传递的appid无效");
- $appSecret=WeiXin111_AppSecret;
- if($appid=="wx1c0dd76b74598921"){
- $appSecret="652057f8e2840a4b0906b417b0911924";
- }
- return array(
- "appSecret"=>$appSecret,
- "needUnionid"=>true,//根据是否为公众号确定是否二次获取unionid
- "needUserInfo"=>true,//获取用户信息
- );
- },function($appid,$state,$userInfo){
- //可以在此处进行$userInfo的持久化工作
- $nickName=$userInfo["nickname"];
- eeglobal_log_handler(LOG_CATALOG,"info","nickName=$nickName");
- });
- exit;
- }catch(Throwable $e){
- $friendMsg=get_class($e)=='GeneralException'?$e->friendmsg:"非常抱歉,获取微信登录信息时发生错误";
- throw new GeneralException("处理业务发生错误:".$e->getMessage(),$friendMsg,LOG_CATALOG,0,$e);
- }
|