fix: update AppID/AppSecret and fix wechatLogin undefined index errors
- Update AppID to wx2deff82b6c422615 - Update AppSecret for new AppID - Fix saveUseInfor: handle missing nickName/avatarUrl from getPhoneNumber - Fix wechatLogin: get openid from jscode2session response Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,8 +15,8 @@ class Cppwechat extends Base
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->Appid = 'wx0847525a15342a46';
|
||||
$this->Appsecret = '71cf8c524580ba6b262e6dc52d44da4c';
|
||||
$this->Appid = 'wx2deff82b6c422615';
|
||||
$this->Appsecret = '447c3e46ce640ad772534c8f9161e1fd';
|
||||
$this->TokenKey = 'ruilai340u20k4';
|
||||
}
|
||||
|
||||
@@ -281,9 +281,11 @@ class Cppwechat extends Base
|
||||
|
||||
if (!isset($apiData['errcode'])) {
|
||||
$sessionKey = $apiData['session_key'];
|
||||
$openid = $apiData['openid'];
|
||||
$errCode = $this->decryptData($sessionKey, $this->Appid, $encryptedData, $iv, $data);
|
||||
if ($errCode == 0) {
|
||||
$record = json_decode($data, true);
|
||||
$record['openid'] = $openid;
|
||||
$res = $this->saveUseInfor($record);
|
||||
return json_encode($res);
|
||||
} else {
|
||||
@@ -301,13 +303,13 @@ class Cppwechat extends Base
|
||||
private function saveUseInfor($record)
|
||||
{
|
||||
$data = array();
|
||||
$data['nickname'] = $record['nickName'];
|
||||
$data['headimg'] = $record['avatarUrl'];
|
||||
$data['nickname'] = isset($record['nickName']) ? $record['nickName'] : 'WeChat User';
|
||||
$data['headimg'] = isset($record['avatarUrl']) ? $record['avatarUrl'] : '';
|
||||
|
||||
$rec = Db::name('wechat_user')->field('uid')->where('openid', $record['openId'])->find();
|
||||
$rec = Db::name('wechat_user')->field('uid')->where('openid', $record['openid'])->find();
|
||||
|
||||
if (empty($rec)) {
|
||||
$data['openid'] = $record['openId'];
|
||||
$data['openid'] = $record['openid'];
|
||||
$data['create_time'] = date('Y-m-d H:i:s');
|
||||
$res = Db::name('wechat_user')->insertGetId($data);
|
||||
$uid = $res;
|
||||
|
||||
Reference in New Issue
Block a user