probe_sms_body.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. """Try different request body shapes for /sms/send."""
  2. import asyncio
  3. import sys
  4. from pathlib import Path
  5. _HERE = Path(__file__).resolve().parent
  6. sys.path.insert(0, str(_HERE.parent / "src"))
  7. from cq2_sdk.env_loader import load_env
  8. load_env(_HERE.parent / ".env")
  9. from cq2_sdk.login import Box996Login, ManualGeetestSolver
  10. HOST = "https://pc-api.996hezi.com"
  11. PATH = "/sms/send"
  12. # 4 个 body 变体: 加 game_id / sms_type / mobile 字段名 / type
  13. CANDIDATES = [
  14. ("with game_id=206923 + type=login", {
  15. "phone": "13800138000", "channel_id": "", "game_id": "206923",
  16. "inviter_uid": "", "needConfirmLogin": True, "type": "login",
  17. }),
  18. ("with game_id=206923 + sms_type=login", {
  19. "phone": "13800138000", "channel_id": "", "game_id": "206923",
  20. "inviter_uid": "", "needConfirmLogin": True, "sms_type": "login",
  21. }),
  22. ("with mobile (different field name) + game_id", {
  23. "mobile": "13800138000", "game_id": "206923",
  24. }),
  25. ("minimal: just phone + game_id", {
  26. "phone": "13800138000", "game_id": "206923",
  27. }),
  28. ]
  29. async def main() -> int:
  30. box = Box996Login(geetest=ManualGeetestSolver(), device_id="00:15:5d:0a:04:00")
  31. print(f"Trying 4 body shapes against {HOST}{PATH}:\n")
  32. for desc, body in CANDIDATES:
  33. try:
  34. r = await box._request("POST", HOST, PATH, json_body=body)
  35. print(f" [200] {desc:<48} code={r.get('code')} msg={r.get('msg', '')[:60]}")
  36. except Exception as e:
  37. from cq2_sdk.login.box_996 import Box996Error
  38. if isinstance(e, Box996Error):
  39. print(f" [4xx] {desc:<48} code={e.code} msg={e.msg[:60]}")
  40. else:
  41. print(f" [err] {desc:<48} {type(e).__name__}: {str(e)[:60]}")
  42. return 0
  43. if __name__ == "__main__":
  44. sys.exit(asyncio.run(main()))