MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / getOpenId

Method getOpenId

wxapp/mxbc.js:166–193  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

164 return this.loginCode;
165 }
166 async getOpenId() {
167 try {
168 let options = {
169 method: 'POST',
170 url: `${API_BASE}/v1/app/code2Session`,
171 headers: this.getMiniHeaders(),
172 data: this.getSignedBody({ miniAppId: MINI_APP_ID, code: await this.getLoginCode(true) })
173 }
174 let { data: result } = await axios.request(options);
175 if (result.code == 0) {
176 this.openId = result.data.openid
177
178 this.unionId = result.data.unionid
179 $.log(`账号[${this.index}] code2Session成功`);
180 return true
181 } else {
182 $.log(`账号[${this.index}] code2Session失败❌ ${result.msg || ""}`);
183 this.ckStatus = false
184
185 console.log(result);
186 return false
187 }
188 } catch (e) {
189 $.log(`账号[${this.index}] code2Session异常❌ ${e.message || e}`);
190 this.ckStatus = false
191 return false
192 }
193 }
194 async loginByWxCode() {
195 try {
196 const ok = await this.getOpenId();

Callers 1

loginByWxCodeMethod · 0.95

Calls 5

getMiniHeadersMethod · 0.95
getSignedBodyMethod · 0.95
getLoginCodeMethod · 0.95
requestMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected