-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathapp.py
More file actions
89 lines (68 loc) · 2.63 KB
/
Copy pathapp.py
File metadata and controls
89 lines (68 loc) · 2.63 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from flask import Flask, request, jsonify
import requests
from urllib.parse import urlparse
app = Flask(__name__)
# -----------------------------
# credits : https://great.thug4ff.com/
# -----------------------------
def _get_openid_headers(base_url):
host = urlparse(base_url).netloc
return {
"Accept": "application/json, text/plain, */*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "en-US,en;q=0.9",
"Connection": "keep-alive",
"Content-Type": "application/json",
"Cookie": "source=pc; region=PK; language=en; "
"mspid2=4b56e8f65e7a8454c2dd9e9f1eaff5cc; "
"datadome=465CY_MInLmrrYVl4rCZo4ltk_j~~fJgn770GVVBXsV~EoF_BnK9xNJwot4cspq7VSzSa77ZwARm_6IpT8twIt941vFi0dR0oAZcJikHRWCoApFKF9eeI8TREH3r0IAl; "
"session_key=x0jshjilr25wwgg993pvlb3wnlwcudct",
"Host": host,
"Origin": base_url,
"Referer": base_url,
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) "
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Mobile Safari/537.36",
"sec-ch-ua": '"Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99"',
"sec-ch-ua-mobile": "?1",
"sec-ch-ua-platform": '"Android"'
}
def get_openid_data(account_id):
payload = {
"app_id": 100067,
"login_id": str(account_id)
}
base_url = "https://shop2game.com"
url = f"{base_url}/api/auth/player_id_login"
headers = _get_openid_headers(base_url)
try:
response = requests.post(url, headers=headers, json=payload, timeout=10)
data = response.json()
print(data)
open_id = data.get("open_id")
if open_id:
return {
"nickname": data.get("nickname"),
"region": data.get("region"),
"account_id": account_id,
"open_id": open_id,
}
else:
return data
except Exception as e:
print("Error:", e)
return {"error": "Failed to get nickname and open_id"}
@app.route("/username", methods=["GET"])
def api_openid():
uid = request.args.get("uid")
if not uid:
return jsonify({"error": "Missing 'uid' parameter"}), 400
result = get_openid_data(uid)
if not result.get("open_id"):
return jsonify(result), 404
return jsonify(result)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug=True)
# Demo : http://127.0.0.1:5000/username?uid=305000592