我從小程序上獲取到相應的openid與userinfo 但是想要插入卻無法 請問一下
有使用過cms的大神 我該如何導入數據庫??把會員資料存入數據庫裡啊?
我已經試過n種方式了 求解拜託
require_once 'wxBizDataCrypt.php';
$appid = '';
$appSecret = '';
$Code = $_GET['Code'];
$url = 'https://api.weixin.qq.com/sns/jscode2session?appid='.$appid.'&secret='.$appSecret.'&js_code='.$Code.'&grant_type=authorization_code';
$apiData = file_get_contents($url);
$rawData =$_GET['rawData'];
$signature =$_GET['signature'];
$encryptedData = $_GET['encryptedData'];
$iv = $_GET['iv'];
if(!isset($apiData['errcode'])){
$sessionkey = json_decode($apiData)->session_key;
$signature2 = sha1($rawData.$sessionkey);
if($signature2 != $signature){
return false;
}
$userInfo = new WXBizDataCrypt($appid, $sessionkey);
$errCode = $userInfo->decryptData($encryptedData, $iv, $data);
if($errCode == 0){
$openId = json_decode($data)->openId;
$avatarUrl = json_decode($data)->avatarUrl;
$gender = json_decode($data)->gender;
$city = json_decode($data)->city;
$nickName = json_decode($data)->nickName;
$country = json_decode($data)->country;
$province = json_decode($data)->province;
}
print_r($data."\n");
}
require('../class/connect.php'); //引入数据库配置文件和公共函数文件
require('../class/db_sql.php'); //引入数据库操作文件
$link=db_connect(); //连接MYSQL
$empire=new mysqlquery(); //声明数据库操作类
$sql=$empire->query("select openid from {$dbtbpre}enewsmember where openId = $openId limit 1");
var_dump($sql);
後面一直有問題所以刪了....
我是先查詢沒有 為false 然後insert到數據庫 但是add跟主表都無法存 每次都是null