File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ class WeChat extends Base
2323 public function __construct (array $ config )
2424 {
2525 parent ::__construct ($ config );
26- $ this ->prepareForComponent ();
2726 }
2827
2928 /**
@@ -58,6 +57,23 @@ public function tokenFromCode(string $code): array
5857 return $ this ->normalizeAccessTokenResponse ($ response ->getBody ()->getContents ());
5958 }
6059
60+ /**
61+ * @param array $componentConfig ['id' => xxx, 'token' => xxx]
62+ *
63+ * @return \Overtrue\Socialite\Providers\WeChat
64+ */
65+ public function withComponent (array $ componentConfig )
66+ {
67+ $ this ->component = $ componentConfig ;
68+
69+ return $ this ;
70+ }
71+
72+ public function getComponent ()
73+ {
74+ return $ this ->component ;
75+ }
76+
6177 protected function getAuthUrl (): string
6278 {
6379 $ path = 'oauth2/authorize ' ;
@@ -84,6 +100,7 @@ protected function buildAuthUrlFromBase(string $url): string
84100 protected function getCodeFields (): array
85101 {
86102 if (!empty ($ this ->component )) {
103+ $ this ->prepareForComponent ();
87104 $ this ->with (array_merge ($ this ->parameters , ['component_appid ' => $ this ->component ['id ' ]]));
88105 }
89106
You can’t perform that action at this time.
0 commit comments