File tree 2 files changed +23
-1
lines changed 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 7
7
8
8
namespace xutl \wechat ;
9
9
10
-
11
10
use Yii ;
12
11
use yii \base \Component ;
13
12
use yii \base \InvalidConfigException ;
Original file line number Diff line number Diff line change @@ -34,6 +34,11 @@ class OAuth extends OAuth2
34
34
*/
35
35
public $ apiBaseUrl = 'https://api.weixin.qq.com ' ;
36
36
37
+ /**
38
+ * @var bool 是否使用openid
39
+ */
40
+ public $ useOpenId = true ;
41
+
37
42
/**
38
43
* 初始化组件
39
44
*/
@@ -47,6 +52,24 @@ public function init()
47
52
}
48
53
}
49
54
55
+ /**
56
+ * @inheritdoc
57
+ */
58
+ protected function defaultNormalizeUserAttributeMap ()
59
+ {
60
+ if ($ this ->useOpenId ) {
61
+ return [
62
+ 'id ' => 'openid ' ,
63
+ 'username ' => 'nickname ' ,
64
+ ];
65
+ } else {
66
+ return [
67
+ 'id ' => 'unionid ' ,
68
+ 'username ' => 'nickname ' ,
69
+ ];
70
+ }
71
+ }
72
+
50
73
/**
51
74
* Composes user authorization URL.
52
75
* @param array $params additional auth GET params.
You can’t perform that action at this time.
0 commit comments