webmain/model/wxgzh/oauthModel.php

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php
class wxgzh_oauthClassModel extends wxgzhModel
{
	
	public function initWxgzh()
	{
		$this->settable('wouser');
	}
	
	/**
	*	调整到获取
	*/
	public function oauthto($dlx='we')
	{
		$this->readwxset();
		if($this->appid==''){
			$this->returnerrmsg($dlx, '没有配置公众号');
			return false;
		}
		$state			= $this->rock->get('state','bang');
		$redurl			= ''.getconfig('outurl',URL).'?d='.$dlx.'&a=oauthback&m=login&state='.$state.'';
		$redirect_uri	= urlencode($redurl);
		$url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$this->appid.'&redirect_uri='.$redirect_uri.'&response_type=code&scope=snsapi_userinfo&state='.$state.'#wechat_redirect';
		$this->rock->location($url);
		return true;
	}
	
	public function returnerrmsg($dlx='we',$errmsg, $ocan='')
	{
		$url = '?d='.$dlx.'&m=login&errmsg='.$this->rock->jm->base64encode($errmsg).''.$ocan.'';
		$this->rock->location($url);
		exit();
	}
	
	/**
	*	得到openid获取用户信息
	*/
	public function oauthback()
	{
		$code	= $this->rock->get('code');
		$state	= $this->rock->get('state');
		if($code=='')return '无法取得微信授权';
		
		$this->readwxset();
		$url 	= 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='.$this->appid.'&secret='.$this->secret.'&code='.$code.'&grant_type=authorization_code';
		$result = c('curl')->getcurl($url);
		$openid = '';
		$access_token = '';
		$errmsg 	= '无法获取微信用户openid';
		if($result != ''){
			$arr	= json_decode($result);
			if(isset($arr->openid))$openid = $arr->openid;
			if(isset($arr->access_token))$access_token = $arr->access_token;
			if(isset($arr->errmsg))$errmsg = $arr->errmsg;
		}
		
		if($openid != ''){
			$this->rock->savecookie('wxopenid', $openid);
			$nuarr 	= $this->getone("`openid`='$openid'");
			$uoid	= 0;
后面还有 56 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。