1.获取微信推送ticket
<?php
/**
* 接受微信推送component_verify_ticket协议
* 每隔10分钟定时推送
/** Error reporting */
error_reporting(E_ALL^E_NOTICE^E_WARNING);
ini_set('display_errors', FALSE);
ini_set('display_startup_errors', FALSE);
//error_reporting(E_ALL);
//ini_set('display_errors', '1');
date_default_timezone_set('Asia/Chongqing');
header('Content-Type: text/html; charset=utf-8');
#连接数据库
require_once "db.php";
require_once "../plugins/wxcrypt/WXBizMsgCrypt.php";
$dbConfig = require('../data/conf/db.php');
$conf = array();
$conf['host'] = $dbConfig['DB_HOST'];
$conf['user'] = $dbConfig['DB_USER'];
$conf['passwd'] = $dbConfig['DB_PWD'];
$conf['dbname'] = $dbConfig['DB_NAME'];
$mysql = new MMysql($conf);
#数据表
$tbName = 'cmf_wx_ticket';
#接收数据
$timeStamp =$_GET['timestamp'];
$nonce =$_GET['nonce'];
$encrypt_type =$_GET['encrypt_type'];
$msg_sign =$_GET['msg_signature'];
$encryptMsg = file_get_contents("php://input");
$result = getVerify_Ticket($mysql, $tbName, $timeStamp, $nonce, $encrypt_type, $msg_sign, $encryptMsg);
echo "success";
#解密
function getVerify_Ticket($mysql, $tbName, $timeStamp, $nonce, $encrypt_type, $msg_sign, $encryptMsg) {
$pc = new WXBizMsgCrypt('maozi1988', 'u94JgWWkmG3tKQ0xn5vglD4sL3NdZTCNaZC8EhrINcn', 'wx7153c50551bb2694');
$xml_tree = new DOMDocument();
$xml_tree->loadXML($encryptMsg);
$array_e = $xml_tree->getElementsByTagName('Encrypt');
$encrypt = $array_e->item(0)->nodeValue;
$format = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><Encrypt><![CDATA[%s]]></Encrypt></xml>";
$from_xml = sprintf($format, $encrypt);
$msg = '';
$errCode = $pc->decryptMsg($msg_sign, $timeStamp, $nonce, $from_xml, $msg);
$tick = $mysql->select($tbName);
if ($errCode == 0) {
$xml = new DOMDocument();
$xml->loadXML($msg);
$array_e = $xml->getElementsByTagName('ComponentVerifyTicket');
$component_verify_ticket = $array_e->item(0)->nodeValue;
if ($tick) {
$tick = $tick[0];
$data = array();
$data['wechat_verifyticket'] = $component_verify_ticket;
$data['uptime'] = time();
$data['upday'] = date("Y-m-d H:i:s", time());
$mysql->where("id='{$tick['id']}'")->update($tbName, $data);
} else {
$data = array();
$data['wechat_verifyticket'] = $component_verify_ticket;
$data['uptime'] = time();
$data['upday'] = date("Y-m-d H:i:s", time());
$mysql->insert->add($tbName, $data);
}
echo "success";
} else {
if ($tick) {
$tick = $tick[0];
$data = array();
$data['wechat_verifyticket'] = $errCode;
$data['uptime'] = time();
$data['upday'] = date("Y-m-d H:i:s", time());
$mysql->where("id='{$tick['id']}'")->update($tbName, $data);
} else {
$data = array();
$data['wechat_verifyticket'] = $errCode;
$data['uptime'] = time();
$data['upday'] = date("Y-m-d H:i:s", time());
$mysql->insert($tbName, $data);
}
echo "success";
}
}
?>
2.工具 数据库操作类
<?php
/**
* Desc: php操作mysql的封装类
* Author zhifeng
* Date: 2015/04/15
* 连接模式:PDO
*/
class MMysql {
protected static $_dbh = null; //静态属性,所有数据库实例共用,避免重复连接数据库
protected $_dbType = 'mysql';
protected $_pconnect = true; //是否使用长连接
protected $_host = 'localhost';
protected $_port = 3306;
protected $_user = 'root';
protected $_pass = 'root';
protected $_dbName = null; //数据库名
protected $_sql = false; //最后一条sql语句
protected $_where = '';
protected $_order = '';
protected $_limit = '';
protected $_field = '*';
protected $_clear = 0; //状态,0表示查询条件干净,1表示查询条件污染
protected $_trans = 0; //事务指令数
/**
* 初始化类
* @param array $conf 数据库配置
*/
public function __construct(array $conf) {
class_exists('PDO') or die("PDO: class not exists.");
$this->_host = $conf['host'];
$this->_port = $conf['port'];
$this->_user = $conf['user'];
$this->_pass = $conf['passwd'];
$this->_dbName = $conf['dbname'];
//连接数据库
if ( is_null(self::$_dbh) ) {
$this->_connect();
}
}
/**
* 连接数据库的方法
*/
protected function _connect() {
$dsn = $this->_dbType.':host='.$this->_host.';port='.$this->_port.';dbname='.$this->_dbName;
$options = $this->_pconnect ? array(PDO::ATTR_PERSISTENT=>true) : array();
try {
$dbh = new PDO($dsn, $this->_user, $this->_pass, $options);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //设置如果sql语句执行错误则抛出异常,事务会自动回滚
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); //禁用prepared statements的仿真效果(防SQL注入)
} catch (PDOException $e) {
die('Connection failed: ' . $e->getMessage());
}
$dbh->exec('SET NAMES utf8');
self::$_dbh = $dbh;
}
/**
* 字段和表名添加 `符号
* 保证指令中使用关键字不出错 针对mysql
* @param string $value
* @return string
*/
protected function _addChar($value) {
if ('*'==$value || false!==strpos($value,'(') || false!==strpos($value,'.') || false!==strpos($value,'`')) {
//如果包含* 或者 使用了sql方法 则不作处理
} elseif (false === strpos($value,'`') ) {
$value = '`'.trim($value).'`';
}
return $value;
}
/**
* 取得数据表的字段信息
* @param string $tbName 表名
* @return array
*/
protected function _tbFields($tbName) {
$sql = 'SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME="'.$tbName.'" AND TABLE_SCHEMA="'.$this->_dbName.'"';
$stmt = self::$_dbh->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$ret = array();
foreach ($result as $key=>$value) {
$ret[$value['COLUMN_NAME']] = 1;
}
return $ret;
}
/**
* 过滤并格式化数据表字段
* @param string $tbName 数据表名
* @param array $data POST提交数据
* @return array $newdata
*/
protected function _dataFormat($tbName,$data) {
if (!is_array($data)) return array();
$table_column = $this->_tbFields($tbName);
$ret=array();
foreach ($data as $key=>$val) {
if (!is_scalar($val)) continue; //值不是标量则跳过
if (array_key_exists($key,$table_column)) {
$key = $this->_addChar($key);
if (is_int($val)) {
$val = intval($val);
} elseif (is_float($val)) {
$val = floatval($val);
} elseif (preg_match('/^\(\w*(\+|\-|\*|\/)?\w*\)$/i', $val)) {
// 支持在字段的值里面直接使用其它字段 ,例如 (score+1) (name) 必须包含括号
$val = $val;
} elseif (is_string($val)) {
$val = '"'.addslashes($val).'"';
}
$ret[$key] = $val;
}
}
return $ret;
}
/**
* 执行查询 主要针对 SELECT, SHOW 等指令
* @param string $sql sql指令
* @return mixed
*/
protected function _doQuery($sql='') {
$this->_sql = $sql;
$pdostmt = self::$_dbh->prepare($this->_sql); //prepare或者query 返回一个PDOStatement
$pdostmt->execute();
$result = $pdostmt->fetchAll(PDO::FETCH_ASSOC);
return $result;
}
/**
* 执行语句 针对 INSERT, UPDATE 以及DELETE,exec结果返回受影响的行数
* @param string $sql sql指令
* @return integer
*/
protected function _doExec($sql='') {
$this->_sql = $sql;
return self::$_dbh->exec($this->_sql);
}
/**
* 执行sql语句,自动判断进行查询或者执行操作
* @param string $sql SQL指令
* @return mixed
*/
public function doSql($sql='') {
$queryIps = 'INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|LOAD DATA|SELECT .* INTO|COPY|ALTER|GRANT|REVOKE|LOCK|UNLOCK';
if (preg_match('/^\s*"?(' . $queryIps . ')\s+/i', $sql)) {
return $this->_doExec($sql);
}
else {
//查询操作
return $this->_doQuery($sql);
}
}
/**
* 获取最近一次查询的sql语句
* @return String 执行的SQL
*/
public function getLastSql() {
return $this->_sql;
}
/**
* 插入方法
* @param string $tbName 操作的数据表名
* @param array $data 字段-值的一维数组
* @return int 受影响的行数
*/
public function insert($tbName,array $data){
$data = $this->_dataFormat($tbName,$data);
if (!$data) return;
$sql = "insert into ".$tbName."(".implode(',',array_keys($data)).") values(".implode(',',array_values($data)).")";
return $this->_doExec($sql);
}
/**
* 删除方法
* @param string $tbName 操作的数据表名
* @return int 受影响的行数
*/
public function delete($tbName) {
//安全考虑,阻止全表删除
if (!trim($this->_where)) return false;
$sql = "delete from ".$tbName." ".$this->_where;
$this->_clear = 1;
$this->_clear();
return $this->_doExec($sql);
}
/**
* 更新函数
* @param string $tbName 操作的数据表名
* @param array $data 参数数组
* @return int 受影响的行数
*/
public function update($tbName,array $data) {
//安全考虑,阻止全表更新
if (!trim($this->_where)) return false;
$data = $this->_dataFormat($tbName,$data);
if (!$data) return;
$valArr = '';
foreach($data as $k=>$v){
$valArr[] = $k.'='.$v;
}
$valStr = implode(',', $valArr);
$sql = "update ".trim($tbName)." set ".trim($valStr)." ".trim($this->_where);
return $this->_doExec($sql);
}
/**
* 查询函数
* @param string $tbName 操作的数据表名
* @return array 结果集
*/
public function select($tbName='') {
$sql = "select ".trim($this->_field)." from ".$tbName." ".trim($this->_where)." ".trim($this->_order)." ".trim($this->_limit);
$this->_clear = 1;
$this->_clear();
return $this->_doQuery(trim($sql));
}
/**
* @param mixed $option 组合条件的二维数组,例:$option['field1'] = array(1,'=>','or')
* @return $this
*/
public function where($option) {
if ($this->_clear>0) $this->_clear();
$this->_where = ' where ';
$logic = 'and';
if (is_string($option)) {
$this->_where .= $option;
}
elseif (is_array($option)) {
foreach($option as $k=>$v) {
if (is_array($v)) {
$relative = isset($v[1]) ? $v[1] : '=';
$logic = isset($v[2]) ? $v[2] : 'and';
$condition = ' ('.$this->_addChar($k).' '.$relative.' '.$v[0].') ';
}
else {
$logic = 'and';
$condition = ' ('.$this->_addChar($k).'='.$v.') ';
}
$this->_where .= isset($mark) ? $logic.$condition : $condition;
$mark = 1;
}
}
return $this;
}
/**
* 设置排序
* @param mixed $option 排序条件数组 例:array('sort'=>'desc')
* @return $this
*/
public function order($option) {
if ($this->_clear>0) $this->_clear();
$this->_order = ' order by ';
if (is_string($option)) {
$this->_order .= $option;
}
elseif (is_array($option)) {
foreach($option as $k=>$v){
$order = $this->_addChar($k).' '.$v;
$this->_order .= isset($mark) ? ','.$order : $order;
$mark = 1;
}
}
return $this;
}
/**
* 设置查询行数及页数
* @param int $page pageSize不为空时为页数,否则为行数
* @param int $pageSize 为空则函数设定取出行数,不为空则设定取出行数及页数
* @return $this
*/
public function limit($page,$pageSize=null) {
if ($this->_clear>0) $this->_clear();
if ($pageSize===null) {
$this->_limit = "limit ".$page;
}
else {
$pageval = intval( ($page - 1) * $pageSize);
$this->_limit = "limit ".$pageval.",".$pageSize;
}
return $this;
}
/**
* 设置查询字段
* @param mixed $field 字段数组
* @return $this
*/
public function field($field){
if ($this->_clear>0) $this->_clear();
if (is_string($field)) {
$field = explode(',', $field);
}
$nField = array_map(array($this,'_addChar'), $field);
$this->_field = implode(',', $nField);
return $this;
}
/**
* 清理标记函数
*/
protected function _clear() {
$this->_where = '';
$this->_order = '';
$this->_limit = '';
$this->_field = '*';
$this->_clear = 0;
}
/**
* 手动清理标记
* @return $this
*/
public function clearKey() {
$this->_clear();
return $this;
}
/**
* 启动事务
* @return void
*/
public function startTrans() {
//数据rollback 支持
if ($this->_trans==0) self::$_dbh->beginTransaction();
$this->_trans++;
return;
}
/**
* 用于非自动提交状态下面的查询提交
* @return boolen
*/
public function commit() {
$result = true;
if ($this->_trans>0) {
$result = self::$_dbh->commit();
$this->_trans = 0;
}
return $result;
}
/**
* 事务回滚
* @return boolen
*/
public function rollback() {
$result = true;
if ($this->_trans>0) {
$result = self::$_dbh->rollback();
$this->_trans = 0;
}
return $result;
}
/**
* 关闭连接
* PHP 在脚本结束时会自动关闭连接。
*/
public function close() {
if (!is_null(self::$_dbh)) self::$_dbh = null;
}
}
3.三方授权入口 thinkphp
#第三方授权
public function autho() {
#判断当前用户是否已经授权
$has_auth = M('wx_user')->where("admin_id='{$this->adminid}'")->find();
if ($has_auth) {
$this->assign('auth', $has_auth);
$this->display();
} else {
#0.配置参数
$config = M('options')->where("option_name='site_options'")->find();
$config = json_decode($config['option_value'], 1);
$com_appid = $config['wx_com_appid'];//三方APPID
$com_appsec = $config['wx_com_appkey'];//三方APPKEY
#1.ticket
$ticket = M('wx_ticket')->find();
if ($ticket['wechat_verifyticket']) {
$ticket_ver = $ticket['wechat_verifyticket'];
} else {
$this->error("ticket错误");
}
#2.三方平台component_access_token 2小时缓存
$com_access = M('wx_com_access')->find();
if (!$com_access) {
$url_com_token = "https://api.weixin.qq.com/cgi-bin/component/api_component_token";
$data = array();
$data['component_appid'] = $com_appid;
$data['component_appsecret'] = $com_appsec;
$data['component_verify_ticket'] = $ticket_ver;
$data = json_encode($data, 1);
$res_com_token = sp_curlJson($url_com_token, $data);
$res_com_token = json_decode($res_com_token, 1);
if (!$res_com_token['component_access_token']) {
$this->error("获取access失败");
} else {
$ins = array();
$ins['access_token'] = $res_com_token['component_access_token'];
$ins['addtime'] = time();
$ins['adddate'] = date("Y-m-d H:i:s", time());
M('wx_com_access')->add($ins);
}
} else {
$diff_time = time() - $com_access['addtime'];
if ($diff_time >= 7100) {
$url_com_token = "https://api.weixin.qq.com/cgi-bin/component/api_component_token";
$data = array();
$data['component_appid'] = $com_appid;
$data['component_appsecret'] = $com_appsec;
$data['component_verify_ticket'] = $ticket_ver;
$data = json_encode($data, 1);
$res_com_token = sp_curlJson($url_com_token, $data);
$res_com_token = json_decode($res_com_token, 1);
if (!$res_com_token['component_access_token']) {
$this->error("获取access失败");
} else {
$ins = array();
$ins['access_token'] = $res_com_token['component_access_token'];
$ins['addtime'] = time();
$ins['adddate'] = date("Y-m-d H:i:s", time());
M('wx_com_access')->where("id='{$com_access['id']}'")->save($ins);
}
}
}
$com_access = M('wx_com_access')->find();
#3.获取预授权码pre_auth_code 有效期10分钟
$com_access_token = $com_access['access_token'];
$url_com_precode = "https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token={$com_access_token}";
$data = array();
$data['component_appid'] = $com_appid;
$data = json_encode($data, 1);
$res_com_precode = sp_curlJson($url_com_precode, $data);
$res_com_precode = json_decode($res_com_precode, 1);
#4.进入授权页面获取公众号授权code,authorization_code
$pre_code = $res_com_precode['pre_auth_code'];//预授权码
$back_uri = "http://{$_SERVER['HTTP_HOST']}/wx/authback.php?admin_id={$this->adminid}";
$redirect_url = "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid={$com_appid}&pre_auth_code={$pre_code}&redirect_uri={$back_uri}&auth_type=3";
redirect($redirect_url);
}
}
4.远程获取
/**
* @desc 封装curl的调用接口,post Json数据的请求方式
*/
function sp_curlJson($url, $data='', $timeout = 25) {
$con = curl_init((string) $url);
curl_setopt($con, CURLOPT_HEADER, false);
curl_setopt($con, CURLOPT_POSTFIELDS, $data);
curl_setopt($con, CURLOPT_POST, true);
curl_setopt($con, CURLOPT_RETURNTRANSFER, true);
curl_setopt($con, CURLOPT_TIMEOUT, (int) $timeout);
curl_setopt($con, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data))
);
return curl_exec($con);
}
5.授权回调
<?php
/** Error reporting */
error_reporting(E_ALL^E_NOTICE^E_WARNING);
ini_set('display_errors', FALSE);
ini_set('display_startup_errors', FALSE);
//error_reporting(E_ALL);
//ini_set('display_errors', '1');
date_default_timezone_set('Asia/Chongqing');
header('Content-Type: text/html; charset=utf-8');
#连接数据库
require_once "db.php";
$dbConfig = require('../data/conf/db.php');
$conf = array();
$conf['host'] = $dbConfig['DB_HOST'];
$conf['user'] = $dbConfig['DB_USER'];
$conf['passwd'] = $dbConfig['DB_PWD'];
$conf['dbname'] = $dbConfig['DB_NAME'];
$mysql = new MMysql($conf);
#数据表
$table_comaccess = "cmf_wx_com_access";//三方access_token表
$table_config = "cmf_options";//微信三方配置表
$table_wxuser = "cmf_wx_user";//第三方用户表
#三方access
$config = $mysql->where("option_name='site_options'")->limit(1)->select($table_config);
$config = $config[0];
$config = json_decode($config['option_value'], 1);
$com_appid = $config['wx_com_appid'];
$com_access = $mysql->limit(1)->select($table_comaccess);
$com_access = $com_access[0]['access_token'];
#接收数据
$code = $_REQUEST['auth_code'];
$admin_id = $_REQUEST['admin_id'];//管理员id
#4使用授权码换取公众号或小程序的接口调用凭据和授权信息 auth_access
$data = array();
$data['component_appid'] = $com_appid;
$data['authorization_code'] = $code;
$data = json_encode($data, 1);
$url_auth_access = "https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token={$com_access}";
$res_auth_access = sp_curlJson($url_auth_access, $data);
$res_auth_access = json_decode($res_auth_access, 1);
$res_appid = $res_auth_access['authorization_info']['authorizer_appid'];
$res_access = $res_auth_access['authorization_info']['authorizer_access_token']; //用户公众号令牌2个小时
$res_refresh = $res_auth_access['authorization_info']['authorizer_refresh_token']; //用户公众号令牌2个小时
#5获取授权方资料信息
#公众号
$res_auth_appid = $res_appid; //用户公众号令牌2个小时
$data = array();
$data['component_appid'] = $com_appid;
$data['authorizer_appid'] = $res_auth_appid;
$url_info_wx = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token={$com_access}";
$data = json_encode($data, 1);
$res_wx = sp_curlJson($url_info_wx, $data);
$res_wx = json_decode($res_wx, 1);
if($res_wx['authorizer_info']) {
$uinfo = $res_wx['authorizer_info'];
$ins = array();
$ins['admin_id'] = $admin_id;
$ins['appid'] = $res_auth_appid;
$ins['nick_name'] = $uinfo['nick_name'];
$ins['head_img'] = $uinfo['head_img'];
$ins['qrcode_url'] = $uinfo['qrcode_url'];
$ins['service_type_info'] = $uinfo['service_type_info']['id'];
$ins['access_token'] = $res_access;
$ins['refresh_token'] = $res_refresh;
$ins['qrcode_url'] = $uinfo['qrcode_url'];
$ins['addtime'] = time();
$ins['adddate'] = date('Y-m-d H:i:s', time());
$ins['tokentime'] = time();
$hasInfo = $mysql->where("admin_id='{$admin_id}'")->limit(1)->select($table_wxuser);
if (!$hasInfo) {
$mysql->insert($table_wxuser, $ins);
} else {
$mysql->where("id='{$hasInfo[0]['id']}'")->update($table_wxuser, $ins);
}
echo "授权成功";
} else {
echo "获取用户信息失败";
}
/**
* @desc 封装curl的调用接口,post Json数据的请求方式
*/
function sp_curlJson($url, $data='', $timeout = 25) {
$con = curl_init((string) $url);
curl_setopt($con, CURLOPT_HEADER, false);
curl_setopt($con, CURLOPT_POSTFIELDS, $data);
curl_setopt($con, CURLOPT_POST, true);
curl_setopt($con, CURLOPT_RETURNTRANSFER, true);
curl_setopt($con, CURLOPT_TIMEOUT, (int) $timeout);
curl_setopt($con, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data))
);
return curl_exec($con);
}
?>
6.相关数据表
--
-- 表的结构 `cmf_wx_com_access`
--
CREATE TABLE `cmf_wx_com_access` (
`id` int(11) NOT NULL,
`access_token` varchar(1000) DEFAULT '0',
`addtime` int(11) DEFAULT '0',
`adddate` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='第三方平台access_token';
--
-- 转存表中的数据 `cmf_wx_com_access`
--
INSERT INTO `cmf_wx_com_access` (`id`, `access_token`, `addtime`, `adddate`) VALUES
(1, '5_sDR2qlfOncGxfOrMInYIwu4EFUTrj4Ox1uaXJ4R9JAAHu2A1Rc8XBLg5WcOWzo62K-cdV4wJ1nMkeIs-7EF9lrKIQ_aH-MZ3jqAwwQIOd_6qcCb9PTjnaV6lzRGV7w-RpFndCDORPP2lqy6GUYZgAAANRS', 1513670387, '2017-12-19 15:59:47');
-- --------------------------------------------------------
--
-- 表的结构 `cmf_wx_ticket`
--
CREATE TABLE `cmf_wx_ticket` (
`id` int(11) NOT NULL,
`wechat_verifyticket` text,
`uptime` int(11) DEFAULT '0',
`upday` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='微信推送component_verify_ticket协议表';
--
-- 转存表中的数据 `cmf_wx_ticket`
--
INSERT INTO `cmf_wx_ticket` (`id`, `wechat_verifyticket`, `uptime`, `upday`) VALUES
(1, 'ticket@@@udzi47PrV75LHsGa0mtHtSdltaprjWKmmSaD2udKJidSkQ0mQDC6D6TU2UJqhwriBikGNuIkfcShTb4_XLecgw', 1513672266, '2017-12-19 16:31:06');
-- --------------------------------------------------------
--
-- 表的结构 `cmf_wx_user`
--
CREATE TABLE `cmf_wx_user` (
`id` int(11) NOT NULL,
`admin_id` int(11) DEFAULT '0' COMMENT '管理员id',
`appid` varchar(500) DEFAULT '0' COMMENT 'APPID',
`nick_name` varchar(200) DEFAULT '0' COMMENT '昵称',
`head_img` varchar(500) DEFAULT '0' COMMENT '头像',
`qrcode_url` varchar(500) DEFAULT '0' COMMENT '二维码',
`service_type_info` int(11) DEFAULT '0' COMMENT '授权方公众号类型,0代表订阅号,1代表由历史老帐号升级后的订阅号,2代表服务号',
`access_token` varchar(500) DEFAULT '0' COMMENT 'token',
`refresh_token` varchar(500) DEFAULT '0' COMMENT 'refresh_token',
`addtime` int(11) DEFAULT '0',
`adddate` datetime DEFAULT NULL,
`tokentime` int(11) DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='第三方授权用户';
--
-- 转存表中的数据 `cmf_wx_user`
--
INSERT INTO `cmf_wx_user` (`id`, `admin_id`, `appid`, `nick_name`, `head_img`, `qrcode_url`, `service_type_info`, `access_token`, `refresh_token`, `addtime`, `adddate`, `tokentime`) VALUES
(1, 80, 'wxe92e550d89fa4f47', 'MiracleMAO', 'http://wx.qlogo.cn/mmopen/Z1OOVwvZOWriaAIelEKzortnibVg0vSMm8aZ5zB8EfFBCY1FEY6vDFClJic3hTjr6iaibqOJxp3XuPXdNvB5LnEPHJSEiaH2pWJRjw/0', 'http://mmbiz.qpic.cn/mmbiz_jpg/70QhES606ZIBiavHV7Uh8pP3fhH5l48jJjDnldp5rX0Vwz1nibaichGicB4JiaWVFFzJcLL2zJrwxHIuvS8WWjeKVUw/0', 1, '5_6Fv4tnzyoQHiuTIhkSNXV83UZ_TvhzH0rNW4_emD6WKvCtb7AzHbHvWxo7X5lEBLfCGCC6yqEMrL1QcOST_xiukgazZjiq0L-PID-rhYf3ABLhgnVAFdi3H3rjx6aPONsCWMITOS-t4-dyPuQCMfALDXJT', 'refreshtoken@@@32N0nEYh9V9a3e-FnpoQaEYoevweYQHaE3iqlGE04eA', 1513670404, '2017-12-19 16:00:04', 1513670404);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `cmf_wx_com_access`
--
ALTER TABLE `cmf_wx_com_access`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `cmf_wx_ticket`
--
ALTER TABLE `cmf_wx_ticket`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `cmf_wx_user`
--
ALTER TABLE `cmf_wx_user`
ADD PRIMARY KEY (`id`);
--
-- 在导出的表使用AUTO_INCREMENT
--
--
-- 使用表AUTO_INCREMENT `cmf_wx_com_access`
--
ALTER TABLE `cmf_wx_com_access`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- 使用表AUTO_INCREMENT `cmf_wx_ticket`
--
ALTER TABLE `cmf_wx_ticket`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- 使用表AUTO_INCREMENT `cmf_wx_user`
--
ALTER TABLE `cmf_wx_user`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;COMMIT;
网友评论