MCPcopy
hub / github.com/smallfawn/QLScriptPublic / request_encrypted

Method request_encrypted

tianyi.py:226–252  ·  view source on GitHub ↗
(self, endpoint: str, params: dict)

Source from the content-addressed store, hash-verified

224 return response.json()
225
226 def request_encrypted(self, endpoint: str, params: dict) -> dict:
227 self.session.headers["imencrypt"] = "1"
228 imrandomnum = generate_random_string(16)
229 imtimestamp = str(int(time.time() * 1000))
230 imencryptkey = encryptmd5(imtimestamp, imrandomnum)
231
232 form_data = {"channelId": CHANNEL_ID, "portal": "45"}
233 form_data.update(params)
234 encrypted_form = encrypt_request(form_data, imrandomnum, imtimestamp, imencryptkey)
235
236 headers = {
237 "imencryptkey": imencryptkey,
238 "imrandomnum": imrandomnum,
239 "imtimestamp": imtimestamp,
240 }
241 url = f"{self.BASE_URL}{endpoint}"
242 response = self.session.post(url, params={"formData": encrypted_form}, headers=headers, timeout=30)
243
244 new_auth = response.headers.get("Authorization")
245 if new_auth:
246 self.token = new_auth
247 self.session.headers["Authorization"] = f"Bearer {new_auth}"
248
249 try:
250 return decrypt_response(response.text, imrandomnum, imtimestamp, imencryptkey)
251 except:
252 return {"raw": response.text}
253
254 def get_user_info(self, mobile: str) -> dict:
255 params = {"channelId": CHANNEL_ID, "portal": "45", "mobile": mobile}

Callers 13

send_stat_messageMethod · 0.95
template_makeMethod · 0.95
get_scoreMethod · 0.95
do_lotteryMethod · 0.95
do_egg_lotteryMethod · 0.95
get_lottery_timesMethod · 0.95
make_new_year_videoMethod · 0.95
ai_agent_chatMethod · 0.95
check_ai_agent_resultMethod · 0.95
query_person_tasksMethod · 0.95

Calls 7

generate_random_stringFunction · 0.85
encryptmd5Function · 0.85
encrypt_requestFunction · 0.85
decrypt_responseFunction · 0.85
timeMethod · 0.45
postMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected