-
Notifications
You must be signed in to change notification settings - Fork 0
/
setAvatarName.php
38 lines (35 loc) · 1.11 KB
/
setAvatarName.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
header("content-type:text/html;charset=utf-8");
include_once __DIR__ . "/common.php";
$data = initPostData();
//设定头像与昵称,使用自定义鉴权,不再调用wx.login。
$token = $data['token'];
$avatarUrl = $data['avatarUrl'];
$newName = $data['nickName'];
if ($newName == "" || is_null($newName) || $newName == "undefined"){
die('{"code":1002,"msg":"请勿传入空值"}');
}
$con = pdo_database();
$redata = array('code'=>10);
if ($token == '') {
die('{"code":1006,"msg":"请先登录"}');
}
if ($token) {
[$openid, $identity, $nickName] = pdoCheckUserPrivilege($con, $token);
}
if ($openid) {
if ($newName) {
update_once($con,"userinfo","nickName",$newName,"openid",$openid,"");
update_once($con,"userinfo","needProfile","0","openid",$openid,"");
}
if ($avatarUrl) {
update_once($con,"userinfo","avatarUrl",$avatarUrl,"openid",$openid,"");
}
}
else {
die('{"code":1002,"msg":"登录态已失效"}');
}
$redata["msg"]="修改成功";
echo json_encode($redata,JSON_UNESCAPED_UNICODE);
$con = null;
// 不包含敏感信息,不再需要进行数据解密。