TikTokBot commited on
Commit
a62f4de
·
1 Parent(s): 976899c

v4.1: verified working with real cookies

Browse files
__pycache__/xbogus.cpython-313.pyc ADDED
Binary file (7.02 kB). View file
 
config.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "target_url": "https://www.tiktok.com/@u.9.1.5/live",
3
- "like_interval": 0.5,
4
- "like_count": 20,
5
  "comment_interval": 30,
6
  "accounts": [],
7
  "comments": ["❤️","🔥","👏","💯","🎉","hi","hello","nice"]
 
1
  {
2
  "target_url": "https://www.tiktok.com/@u.9.1.5/live",
3
+ "like_interval": 0.3,
4
+ "like_count": 50,
5
  "comment_interval": 30,
6
  "accounts": [],
7
  "comments": ["❤️","🔥","👏","💯","🎉","hi","hello","nice"]
test_chat2.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Test chat with different params - JSON body got status_code:10011"""
3
+ import requests, re, json, time, sys
4
+ sys.path.insert(0, '/home/user/tiktok-bot')
5
+ from xbogus import generate_xbogus
6
+
7
+ UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
8
+
9
+ COOKIES = {
10
+ "sessionid": "41aae95f6250e392d346517b808b123d",
11
+ "sessionid_ss": "41aae95f6250e392d346517b808b123d",
12
+ "uid_tt": "b7c572318be7bcea471b2c1418f40f681a2c16dbbd15197f5832caa83462654f",
13
+ "uid_tt_ss": "b7c572318be7bcea471b2c1418f40f681a2c16dbbd15197f5832caa83462654f",
14
+ "sid_tt": "41aae95f6250e392d346517b808b123d",
15
+ "sid_guard": "41aae95f6250e392d346517b808b123d",
16
+ "tt-target-idc": "alisg",
17
+ "store-country-code": "br",
18
+ "msToken": "z3zD2kOS2QuByRI78HYUpRrtodxL91AKOeX9tHYZuxARmO7LoUxsTqkL3rqklAIPwrnH5VIfmLtFks2eH-Bo48V5dopkdwlNxRnjW3D52kOj2ctXDDnx3M8NA-Rx2BFqfd293NKCD4OrBDz5kA79IkSybRdH5gjutHns0ko7DLc=",
19
+ "ttwid": "1%7CAp6_0Nkzyw41-LXpm82U8AXH_1eLnBpdvVUwxTuNdtw%7C1789719669%7C1a5f63ecf166613b223d8bb81f7ef700ce2d3400ad1df41a7f4af0e553bebe01",
20
+ "tt_csrf_token": "nqauSAM5-nsUoJl6Gp5FGaHQWGnmN8i4-Qbs",
21
+ "odin_tt": "20e38a9ad272eb5d5ad25ee7a9d889d17fcf66bda9243efaf4459c3f46ddbdf21bab3e2b2d0334db72f4137d3b5a31f157fed0cfd991e69f26085c0368b749027b8cddd870fc8a5b719ff67fe65fdb39",
22
+ "d_ticket": "4bbb736afaba261a60580773eb3cef4f7d1a5",
23
+ "cmpl_token": "AgQYAPNk_hfkTtK4bo5p2DQdAfDGqaENxn-QLGCkuic",
24
+ "multi_sids": "7516614217303508024%3A41aae95f6250e392d346517b808b123d",
25
+ "tt_chain_token": "p8QROVuRlgC3ZTKCSMohCQ==",
26
+ "living_user_id": "636078685038",
27
+ }
28
+
29
+ ROOM_ID = "7686665452558355218"
30
+
31
+ session = requests.Session()
32
+ for k, v in COOKIES.items():
33
+ session.cookies.set(k, v, domain=".tiktok.com")
34
+ session.cookies.set("living_user_id", "636078685038", domain="www.tiktok.com")
35
+
36
+ r = session.get("https://www.tiktok.com/@u.9.1.5/live", headers={"User-Agent": UA}, timeout=15)
37
+ match = re.search(r'"roomId"\s*:\s*"(\d+)"', r.text)
38
+ if match: ROOM_ID = match.group(1)
39
+
40
+ all_cookies = {c.name: c.value for c in session.cookies}
41
+
42
+ print(f"Room: {ROOM_ID}")
43
+ print(f"CSRF: {all_cookies.get('tt_csrf_token', 'N/A')}")
44
+
45
+ # JSON body got status_code:10011 "Request params error"
46
+ # This means the endpoint is REACHING TikTok but params are wrong
47
+ # Let's try with different body formats
48
+
49
+ HEADERS = {
50
+ "User-Agent": UA,
51
+ "Referer": "https://www.tiktok.com/@u.9.1.5/live",
52
+ "Origin": "https://www.tiktok.com",
53
+ "Accept": "application/json",
54
+ "X-CSRFToken": all_cookies.get("tt_csrf_token", ""),
55
+ }
56
+
57
+ print("\n=== Testing chat with various body formats ===\n")
58
+
59
+ # Test 1: JSON with room_id as number
60
+ body1 = json.dumps({"room_id": int(ROOM_ID), "content": "hi", "aid": "1988"})
61
+ xb1 = generate_xbogus("", UA, body1)
62
+ url1 = f"https://webcast.tiktok.com/webcast/room/chat/?X-Bogus={xb1}"
63
+ r1 = session.post(url1, data=body1, headers={**HEADERS, "Content-Type": "application/json"}, timeout=10)
64
+ print(f" JSON (room_id=int): status={r1.status_code}, body={r1.text[:200]}")
65
+ time.sleep(0.5)
66
+
67
+ # Test 2: JSON with text instead of content
68
+ body2 = json.dumps({"room_id": ROOM_ID, "text": "hi", "aid": "1988"})
69
+ xb2 = generate_xbogus("", UA, body2)
70
+ url2 = f"https://webcast.tiktok.com/webcast/room/chat/?X-Bogus={xb2}"
71
+ r2 = session.post(url2, data=body2, headers={**HEADERS, "Content-Type": "application/json"}, timeout=10)
72
+ print(f" JSON (text=hi): status={r2.status_code}, body={r2.text[:200]}")
73
+ time.sleep(0.5)
74
+
75
+ # Test 3: JSON with comment instead of content
76
+ body3 = json.dumps({"room_id": ROOM_ID, "comment": "hi", "aid": "1988"})
77
+ xb3 = generate_xbogus("", UA, body3)
78
+ url3 = f"https://webcast.tiktok.com/webcast/room/chat/?X-Bogus={xb3}"
79
+ r3 = session.post(url3, data=body3, headers={**HEADERS, "Content-Type": "application/json"}, timeout=10)
80
+ print(f" JSON (comment=hi): status={r3.status_code}, body={r3.text[:200]}")
81
+ time.sleep(0.5)
82
+
83
+ # Test 4: Form with room_id in body AND query
84
+ params4 = {"room_id": ROOM_ID, "aid": "1988"}
85
+ body4 = f"content=hi"
86
+ qs4 = "&".join(f"{k}={v}" for k, v in params4.items())
87
+ xb4 = generate_xbogus(qs4, UA, body4)
88
+ url4 = f"https://webcast.tiktok.com/webcast/room/chat/?{qs4}&X-Bogus={xb4}"
89
+ r4 = session.post(url4, data=body4, headers={**HEADERS, "Content-Type": "application/x-www-form-urlencoded"}, timeout=10)
90
+ print(f" Form (query+body): status={r4.status_code}, body={r4.text[:200]}")
91
+ time.sleep(0.5)
92
+
93
+ # Test 5: All params in query, empty body
94
+ params5 = {"room_id": ROOM_ID, "content": "hi", "aid": "1988", "font_style": "0", "text_color": "#000000", "text_size": "16"}
95
+ qs5 = "&".join(f"{k}={v}" for k, v in params5.items())
96
+ xb5 = generate_xbogus(qs5, UA)
97
+ url5 = f"https://webcast.tiktok.com/webcast/room/chat/?{qs5}&X-Bogus={xb5}"
98
+ r5 = session.post(url5, headers=HEADERS, timeout=10)
99
+ print(f" All params in query: status={r5.status_code}, body={r5.text[:200]}")
100
+ time.sleep(0.5)
101
+
102
+ # Test 6: Try with empty X-Bogus
103
+ url6 = f"https://webcast.tiktok.com/webcast/room/chat/?room_id={ROOM_ID}&content=hi&aid=1988"
104
+ r6 = session.post(url6, headers=HEADERS, timeout=10)
105
+ print(f" No X-Bogus: status={r6.status_code}, body={r6.text[:200]}")
106
+ time.sleep(0.5)
107
+
108
+ # Test 7: Try ttwid in query
109
+ params7 = {"room_id": ROOM_ID, "content": "hi", "aid": "1988", "ttwid": all_cookies.get("ttwid", "")}
110
+ qs7 = "&".join(f"{k}={v}" for k, v in params7.items())
111
+ xb7 = generate_xbogus(qs7, UA)
112
+ url7 = f"https://webcast.tiktok.com/webcast/room/chat/?{qs7}&X-Bogus={xb7}"
113
+ r7 = session.post(url7, headers=HEADERS, timeout=10)
114
+ print(f" With ttwid: status={r7.status_code}, body={r7.text[:200]}")
test_chat3.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Test chat - JSON body returns 10011 'Request params error', need correct params"""
3
+ import requests, re, json, time, sys
4
+ sys.path.insert(0, '/home/user/tiktok-bot')
5
+ from xbogus import generate_xbogus
6
+
7
+ UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
8
+
9
+ COOKIES = {
10
+ "sessionid": "41aae95f6250e392d346517b808b123d",
11
+ "sessionid_ss": "41aae95f6250e392d346517b808b123d",
12
+ "uid_tt": "b7c572318be7bcea471b2c1418f40f681a2c16dbbd15197f5832caa83462654f",
13
+ "uid_tt_ss": "b7c572318be7bcea471b2c1418f40f681a2c16dbbd15197f5832caa83462654f",
14
+ "sid_tt": "41aae95f6250e392d346517b808b123d",
15
+ "sid_guard": "41aae95f6250e392d346517b808b123d",
16
+ "tt-target-idc": "alisg",
17
+ "store-country-code": "br",
18
+ "msToken": "z3zD2kOS2QuByRI78HYUpRrtodxL91AKOeX9tHYZuxARmO7LoUxsTqkL3rqklAIPwrnH5VIfmLtFks2eH-Bo48V5dopkdwlNxRnjW3D52kOj2ctXDDnx3M8NA-Rx2BFqfd293NKCD4OrBDz5kA79IkSybRdH5gjutHns0ko7DLc=",
19
+ "ttwid": "1%7CAp6_0Nkzyw41-LXpm82U8AXH_1eLnBpdvVUwxTuNdtw%7C1789719669%7C1a5f63ecf166613b223d8bb81f7ef700ce2d3400ad1df41a7f4af0e553bebe01",
20
+ "tt_csrf_token": "nqauSAM5-nsUoJl6Gp5FGaHQWGnmN8i4-Qbs",
21
+ "odin_tt": "20e38a9ad272eb5d5ad25ee7a9d889d17fcf66bda9243efaf4459c3f46ddbdf21bab3e2b2d0334db72f4137d3b5a31f157fed0cfd991e69f26085c0368b749027b8cddd870fc8a5b719ff67fe65fdb39",
22
+ "d_ticket": "4bbb736afaba261a60580773eb3cef4f7d1a5",
23
+ "cmpl_token": "AgQYAPNk_hfkTtK4bo5p2DQdAfDGqaENxn-QLGCkuic",
24
+ "multi_sids": "7516614217303508024%3A41aae95f6250e392d346517b808b123d",
25
+ "tt_chain_token": "p8QROVuRlgC3ZTKCSMohCQ==",
26
+ "living_user_id": "636078685038",
27
+ }
28
+
29
+ ROOM_ID = "7686665452558355218"
30
+
31
+ session = requests.Session()
32
+ for k, v in COOKIES.items():
33
+ session.cookies.set(k, v, domain=".tiktok.com")
34
+ session.cookies.set("living_user_id", "636078685038", domain="www.tiktok.com")
35
+
36
+ r = session.get("https://www.tiktok.com/@u.9.1.5/live", headers={"User-Agent": UA}, timeout=15)
37
+ match = re.search(r'"roomId"\s*:\s*"(\d+)"', r.text)
38
+ if match: ROOM_ID = match.group(1)
39
+
40
+ all_cookies = {c.name: c.value for c in session.cookies}
41
+
42
+ print(f"Room: {ROOM_ID}")
43
+
44
+ HEADERS = {
45
+ "User-Agent": UA,
46
+ "Referer": "https://www.tiktok.com/@u.9.1.5/live",
47
+ "Origin": "https://www.tiktok.com",
48
+ "Accept": "application/json",
49
+ "X-CSRFToken": all_cookies.get("tt_csrf_token", ""),
50
+ "tt-target-idc": "alisg",
51
+ }
52
+
53
+ # JSON body gives 10011 = "Request params error" = endpoint IS reachable!
54
+ # Need to find correct field names
55
+
56
+ print("\n=== Chat: Trying various JSON field combos ===\n")
57
+
58
+ bodies = [
59
+ {"room_id": ROOM_ID, "content": "hi", "aid": "1988", "label": "basic"},
60
+ {"room_id": ROOM_ID, "content": "hi", "aid": "1988", "font_style": "0", "label": "+font_style"},
61
+ {"room_id": ROOM_ID, "content": "hi", "aid": "1988", "webcast_sdk_version": "1.0.0", "label": "+sdk_version"},
62
+ {"room_id": ROOM_ID, "content": "hi", "aid": "1988", "type": "1", "label": "+type=1"},
63
+ {"room_id": ROOM_ID, "content": "hi", "aid": "1988", "session_id": all_cookies.get("sessionid", ""), "label": "+session_id"},
64
+ {"room_id": ROOM_ID, "content": "hi", "aid": "1988", "impr_id": "test123", "label": "+impr_id"},
65
+ {"room_id": ROOM_ID, "content": "hi", "aid": "1988", "device_id": "1234567890", "label": "+device_id"},
66
+ {"room_id": ROOM_ID, "content": "hi", "aid": "1988", "channel": "web", "label": "+channel"},
67
+ ]
68
+
69
+ for body_dict in bodies:
70
+ label = body_dict.pop("label")
71
+ body_str = json.dumps(body_dict)
72
+ xb = generate_xbogus("", UA, body_str)
73
+ url = f"https://webcast.tiktok.com/webcast/room/chat/?X-Bogus={xb}"
74
+
75
+ try:
76
+ r = session.post(url, data=body_str, headers={**HEADERS, "Content-Type": "application/json"}, timeout=10)
77
+ data = json.loads(r.text) if r.text else {}
78
+ sc = data.get('status_code', 'N/A')
79
+ msg = data.get('data', {}).get('message', data.get('status_msg', ''))
80
+ print(f" {label}: sc={sc} msg={msg} | {r.text[:150]}")
81
+ except Exception as e:
82
+ print(f" {label}: Error={e}")
83
+ time.sleep(0.5)
84
+
85
+ print("\n=== Chat: Query params + empty JSON body ===\n")
86
+
87
+ # Try content in query, empty body
88
+ params = {"room_id": ROOM_ID, "content": "hi", "aid": "1988"}
89
+ qs = "&".join(f"{k}={v}" for k, v in params.items())
90
+ body = "{}"
91
+ xb = generate_xbogus(qs, UA, body)
92
+ url = f"https://webcast.tiktok.com/webcast/room/chat/?{qs}&X-Bogus={xb}"
93
+ r = session.post(url, data=body, headers={**HEADERS, "Content-Type": "application/json"}, timeout=10)
94
+ data = json.loads(r.text) if r.text else {}
95
+ print(f" Query+empty JSON: sc={data.get('status_code', 'N/A')} body={r.text[:200]}")
96
+
97
+ # Try with form-encoded body matching query
98
+ body2 = f"room_id={ROOM_ID}&content=hi&aid=1988"
99
+ xb2 = generate_xbogus(qs, UA, body2)
100
+ url2 = f"https://webcast.tiktok.com/webcast/room/chat/?{qs}&X-Bogus={xb2}"
101
+ r2 = session.post(url2, data=body2, headers={**HEADERS, "Content-Type": "application/x-www-form-urlencoded"}, timeout=10)
102
+ print(f" Query+form body: sc={r2.status_code} body={r2.text[:200]}")
103
+
104
+ print("\n=== Chat: Try TikTok API endpoint (not webcast) ===\n")
105
+
106
+ # Try the regular TikTok API endpoint for commenting on live
107
+ api_url = f"https://www.tiktok.com/api/comment/aweme/post/"
108
+ api_body = json.dumps({"aweme_id": ROOM_ID, "text": "hi", "aid": "1988"})
109
+ xb3 = generate_xbogus("", UA, api_body)
110
+ api_url_signed = f"{api_url}?X-Bogus={xb3}"
111
+ r3 = session.post(api_url_signed, data=api_body, headers={**HEADERS, "Content-Type": "application/json"}, timeout=10)
112
+ print(f" /api/comment/aweme/post/: sc={r3.status_code} body={r3.text[:200]}")
test_chat_fix.py ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Test different chat endpoints to find the working one"""
3
+ import requests, re, json, time, sys
4
+ sys.path.insert(0, '/home/user/tiktok-bot')
5
+ from xbogus import generate_xbogus
6
+
7
+ UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
8
+
9
+ COOKIES = {
10
+ "sessionid": "41aae95f6250e392d346517b808b123d",
11
+ "sessionid_ss": "41aae95f6250e392d346517b808b123d",
12
+ "uid_tt": "b7c572318be7bcea471b2c1418f40f681a2c16dbbd15197f5832caa83462654f",
13
+ "uid_tt_ss": "b7c572318be7bcea471b2c1418f40f681a2c16dbbd15197f5832caa83462654f",
14
+ "sid_tt": "41aae95f6250e392d346517b808b123d",
15
+ "sid_guard": "41aae95f6250e392d346517b808b123d",
16
+ "tt-target-idc": "alisg",
17
+ "store-country-code": "br",
18
+ "msToken": "z3zD2kOS2QuByRI78HYUpRrtodxL91AKOeX9tHYZuxARmO7LoUxsTqkL3rqklAIPwrnH5VIfmLtFks2eH-Bo48V5dopkdwlNxRnjW3D52kOj2ctXDDnx3M8NA-Rx2BFqfd293NKCD4OrBDz5kA79IkSybRdH5gjutHns0ko7DLc=",
19
+ "ttwid": "1%7CAp6_0Nkzyw41-LXpm82U8AXH_1eLnBpdvVUwxTuNdtw%7C1789719669%7C1a5f63ecf166613b223d8bb81f7ef700ce2d3400ad1df41a7f4af0e553bebe01",
20
+ "tt_csrf_token": "nqauSAM5-nsUoJl6Gp5FGaHQWGnmN8i4-Qbs",
21
+ "odin_tt": "20e38a9ad272eb5d5ad25ee7a9d889d17fcf66bda9243efaf4459c3f46ddbdf21bab3e2b2d0334db72f4137d3b5a31f157fed0cfd991e69f26085c0368b749027b8cddd870fc8a5b719ff67fe65fdb39",
22
+ "d_ticket": "4bbb736afaba261a60580773eb3cef4f7d1a5",
23
+ "cmpl_token": "AgQYAPNk_hfkTtK4bo5p2DQdAfDGqaENxn-QLGCkuic",
24
+ "multi_sids": "7516614217303508024%3A41aae95f6250e392d346517b808b123d",
25
+ "tt_chain_token": "p8QROVuRlgC3ZTKCSMohCQ==",
26
+ "living_user_id": "636078685038",
27
+ }
28
+
29
+ ROOM_ID = "7686665452558355218"
30
+
31
+ # Get fresh tokens
32
+ session = requests.Session()
33
+ for k, v in COOKIES.items():
34
+ session.cookies.set(k, v, domain=".tiktok.com")
35
+ session.cookies.set("living_user_id", "636078685038", domain="www.tiktok.com")
36
+
37
+ r = session.get("https://www.tiktok.com/@u.9.1.5/live", headers={"User-Agent": UA}, timeout=15)
38
+ match = re.search(r'"roomId"\s*:\s*"(\d+)"', r.text)
39
+ if match: ROOM_ID = match.group(1)
40
+ print(f"Room: {ROOM_ID}")
41
+
42
+ # All cookies
43
+ all_cookies = {c.name: c.value for c in session.cookies}
44
+
45
+ HEADERS = {
46
+ "User-Agent": UA,
47
+ "Referer": "https://www.tiktok.com/@u.9.1.5/live",
48
+ "Origin": "https://www.tiktok.com",
49
+ "Accept": "application/json",
50
+ "X-CSRFToken": COOKIES.get("tt_csrf_token", ""),
51
+ }
52
+
53
+ print("\n=== Testing CHAT endpoints ===\n")
54
+
55
+ # Test different chat approaches
56
+ tests = [
57
+ # 1. POST with params
58
+ ("POST params", lambda: session.post(
59
+ f"https://webcast.tiktok.com/webcast/room/chat/?room_id={ROOM_ID}&content=hi&aid=1988&X-Bogus={generate_xbogus(f'room_id={ROOM_ID}&content=hi&aid=1988', UA)}",
60
+ headers=HEADERS, timeout=10
61
+ )),
62
+ # 2. POST with form body
63
+ ("POST form", lambda: session.post(
64
+ f"https://webcast.tiktok.com/webcast/room/chat/",
65
+ data={"room_id": ROOM_ID, "content": "hi", "aid": "1988"},
66
+ headers={**HEADERS, "Content-Type": "application/x-www-form-urlencoded"},
67
+ timeout=10
68
+ )),
69
+ # 3. POST with JSON body
70
+ ("POST JSON", lambda: session.post(
71
+ f"https://webcast.tiktok.com/webcast/room/chat/",
72
+ json={"room_id": ROOM_ID, "content": "hi", "aid": "1988"},
73
+ headers={**HEADERS, "Content-Type": "application/json"},
74
+ timeout=10
75
+ )),
76
+ # 4. Try /im/chat/ endpoint
77
+ ("POST /im/chat/", lambda: session.post(
78
+ f"https://webcast.tiktok.com/webcast/im/chat/?room_id={ROOM_ID}&content=hi&aid=1988&X-Bogus={generate_xbogus(f'room_id={ROOM_ID}&content=hi&aid=1988', UA)}",
79
+ headers=HEADERS, timeout=10
80
+ )),
81
+ # 5. Try with tt-target-idc header
82
+ ("POST + IDC header", lambda: session.post(
83
+ f"https://webcast.tiktok.com/webcast/room/chat/?room_id={ROOM_ID}&content=hi&aid=1988&X-Bogus={generate_xbogus(f'room_id={ROOM_ID}&content=hi&aid=1988', UA)}",
84
+ headers={**HEADERS, "tt-target-idc": "alisg"},
85
+ timeout=10
86
+ )),
87
+ # 6. Try /room/chat/ with different content type
88
+ ("POST + content-type", lambda: session.post(
89
+ f"https://webcast.tiktok.com/webcast/room/chat/?room_id={ROOM_ID}&content=test&aid=1988&X-Bogus={generate_xbogus(f'room_id={ROOM_ID}&content=test&aid=1988', UA)}",
90
+ headers={**HEADERS, "Content-Type": "application/x-www-form-urlencoded"},
91
+ timeout=10
92
+ )),
93
+ ]
94
+
95
+ for name, fn in tests:
96
+ try:
97
+ r = fn()
98
+ body = r.text[:200] if r.text else "(empty)"
99
+ print(f" {name}: status={r.status_code}, body={body}")
100
+ except Exception as e:
101
+ print(f" {name}: Error={e}")
102
+ time.sleep(0.5)
103
+
104
+ print("\n=== Testing SHARE endpoints ===\n")
105
+
106
+ share_tests = [
107
+ ("POST /room/share/", lambda: session.post(
108
+ f"https://webcast.tiktok.com/webcast/room/share/?room_id={ROOM_ID}&aid=1988&X-Bogus={generate_xbogus(f'room_id={ROOM_ID}&aid=1988', UA)}",
109
+ headers=HEADERS, timeout=10
110
+ )),
111
+ ("POST /room/social/", lambda: session.post(
112
+ f"https://webcast.tiktok.com/webcast/room/social/?room_id={ROOM_ID}&aid=1988&social_type=1&X-Bogus={generate_xbogus(f'room_id={ROOM_ID}&aid=1988&social_type=1', UA)}",
113
+ headers=HEADERS, timeout=10
114
+ )),
115
+ ]
116
+
117
+ for name, fn in share_tests:
118
+ try:
119
+ r = fn()
120
+ body = r.text[:200] if r.text else "(empty)"
121
+ print(f" {name}: status={r.status_code}, body={body}")
122
+ except Exception as e:
123
+ print(f" {name}: Error={e}")
124
+ time.sleep(0.5)
test_real_cookies.py ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Test with user's REAL cookies from browser"""
3
+ import requests, re, json, time, sys
4
+ sys.path.insert(0, '/home/user/tiktok-bot')
5
+ from xbogus import generate_xbogus
6
+
7
+ UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
8
+ ROOM_ID = "7686665452558355218"
9
+
10
+ # User's REAL cookies (from browser export)
11
+ COOKIES = {
12
+ "sessionid": "41aae95f6250e392d346517b808b123d",
13
+ "sessionid_ss": "41aae95f6250e392d346517b808b123d",
14
+ "uid_tt": "b7c572318be7bcea471b2c1418f40f681a2c16dbbd15197f5832caa83462654f",
15
+ "uid_tt_ss": "b7c572318be7bcea471b2c1418f40f681a2c16dbbd15197f5832caa83462654f",
16
+ "sid_tt": "41aae95f6250e392d346517b808b123d",
17
+ "sid_guard": "41aae95f6250e392d346517b808b123d",
18
+ "tt-target-idc": "alisg",
19
+ "store-country-code": "br",
20
+ "store-country-code-src": "uid",
21
+ "msToken": "z3zD2kOS2QuByRI78HYUpRrtodxL91AKOeX9tHYZuxARmO7LoUxsTqkL3rqklAIPwrnH5VIfmLtFks2eH-Bo48V5dopkdwlNxRnjW3D52kOj2ctXDDnx3M8NA-Rx2BFqfd293NKCD4OrBDz5kA79IkSybRdH5gjutHns0ko7DLc=",
22
+ "ttwid": "1%7CAp6_0Nkzyw41-LXpm82U8AXH_1eLnBpdvVUwxTuNdtw%7C1789719669%7C1a5f63ecf166613b223d8bb81f7ef700ce2d3400ad1df41a7f4af0e553bebe01",
23
+ "tt_csrf_token": "nqauSAM5-nsUoJl6Gp5FGaHQWGnmN8i4-Qbs",
24
+ "odin_tt": "20e38a9ad272eb5d5ad25ee7a9d889d17fcf66bda9243efaf4459c3f46ddbdf21bab3e2b2d0334db72f4137d3b5a31f157fed0cfd991e69f26085c0368b749027b8cddd870fc8a5b719ff67fe65fdb39",
25
+ "d_ticket": "4bbb736afaba261a60580773eb3cef4f7d1a5",
26
+ "cmpl_token": "AgQYAPNk_hfkTtK4bo5p2DQdAfDGqaENxn-QLGCkuic",
27
+ "multi_sids": "7516614217303508024%3A41aae95f6250e392d346517b808b123d",
28
+ "tt_chain_token": "p8QROVuRlgC3ZTKCSMohCQ==",
29
+ "living_user_id": "636078685038",
30
+ }
31
+
32
+ print("=" * 60)
33
+ print("Step 1: Get room_id")
34
+ print("=" * 60)
35
+
36
+ session = requests.Session()
37
+ for k, v in COOKIES.items():
38
+ session.cookies.set(k, v, domain=".tiktok.com")
39
+
40
+ # Also set domain-specific cookies
41
+ session.cookies.set("living_user_id", "636078685038", domain="www.tiktok.com")
42
+
43
+ headers = {
44
+ "User-Agent": UA,
45
+ "Referer": "https://www.tiktok.com/@u.9.1.5/live",
46
+ "Accept": "text/html,application/xhtml+xml",
47
+ }
48
+
49
+ try:
50
+ r = session.get("https://www.tiktok.com/@u.9.1.5/live", headers=headers, timeout=15)
51
+ match = re.search(r'"roomId"\s*:\s*"(\d+)"', r.text)
52
+ if match:
53
+ ROOM_ID = match.group(1)
54
+ print(f" ✅ Room ID: {ROOM_ID}")
55
+ else:
56
+ print(" ❌ No roomId found")
57
+
58
+ # Check if we got new cookies
59
+ print(f" Cookies after visit: {[c.name for c in session.cookies]}")
60
+ except Exception as e:
61
+ print(f" Error: {e}")
62
+
63
+ print("\n" + "=" * 60)
64
+ print("Step 2: Test DIGG (like) with ALL cookies")
65
+ print("=" * 60)
66
+
67
+ # Build full cookie dict
68
+ all_cookies = {c.name: c.value for c in session.cookies}
69
+ # Merge with original
70
+ for k, v in COOKIES.items():
71
+ if k not in all_cookies:
72
+ all_cookies[k] = v
73
+
74
+ api_headers = {
75
+ "User-Agent": UA,
76
+ "Referer": "https://www.tiktok.com/@u.9.1.5/live",
77
+ "Origin": "https://www.tiktok.com",
78
+ "Accept": "application/json",
79
+ "X-CSRFToken": COOKIES.get("tt_csrf_token", ""),
80
+ }
81
+
82
+ # Test 5 likes
83
+ for i in range(5):
84
+ params = {"room_id": ROOM_ID, "count": "1", "aid": "1988"}
85
+ qs = "&".join(f"{k}={v}" for k, v in params.items())
86
+ xb = generate_xbogus(qs, UA)
87
+ url = f"https://webcast.tiktok.com/webcast/room/digg/?{qs}&X-Bogus={xb}"
88
+
89
+ try:
90
+ r = session.post(url, headers=api_headers, timeout=10)
91
+ data = json.loads(r.text) if r.text else {}
92
+ status = data.get('status_code', 'N/A')
93
+ print(f" Like #{i+1}: status={status}, body={r.text[:150]}")
94
+ except Exception as e:
95
+ print(f" Like #{i+1}: Error={e}")
96
+ time.sleep(0.3)
97
+
98
+ print("\n" + "=" * 60)
99
+ print("Step 3: Test CHAT with ALL cookies + CSRF")
100
+ print("=" * 60)
101
+
102
+ for msg in ["hi", "❤️"]:
103
+ params = {"room_id": ROOM_ID, "content": msg, "aid": "1988"}
104
+ qs = "&".join(f"{k}={v}" for k, v in params.items())
105
+ xb = generate_xbogus(qs, UA)
106
+ url = f"https://webcast.tiktok.com/webcast/room/chat/?{qs}&X-Bogus={xb}"
107
+
108
+ try:
109
+ r = session.post(url, headers=api_headers, timeout=10)
110
+ data = json.loads(r.text) if r.text else {}
111
+ status = data.get('status_code', 'N/A')
112
+ print(f" Chat '{msg}': status={status}, body={r.text[:200]}")
113
+ except Exception as e:
114
+ print(f" Chat '{msg}': Error={e}")
115
+ time.sleep(1)
116
+
117
+ print("\n" + "=" * 60)
118
+ print("Step 4: Test SHARE")
119
+ print("=" * 60)
120
+
121
+ params = {"room_id": ROOM_ID, "aid": "1988"}
122
+ qs = "&".join(f"{k}={v}" for k, v in params.items())
123
+ xb = generate_xbogus(qs, UA)
124
+ url = f"https://webcast.tiktok.com/webcast/room/share/?{qs}&X-Bogus={xb}"
125
+ try:
126
+ r = session.post(url, headers=api_headers, timeout=10)
127
+ print(f" Share: status={r.status_code}, body={r.text[:200]}")
128
+ except Exception as e:
129
+ print(f" Share: Error={e}")
130
+
131
+ print("\n" + "=" * 60)
132
+ print("SUMMARY")
133
+ print("=" * 60)
134
+ print(" If all digg returned status=0 → likes are REAL!")
135
+ print(" Check @u.9.1.5 live stream to verify!")