MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / hyid

Function hyid

wxapp/quanmianshidai.py:636–665  ·  view source on GitHub ↗
(code, token)

Source from the content-addressed store, hash-verified

634
635
636def hyid(code, token):
637 url = "https://sg01.purcotton.com/api/friend/list?page=1&page_size=50"
638 headers = create_headers(code, token)
639
640 try:
641 response = requests.get(url, headers=headers)
642 response.raise_for_status() # 确保响应状态为200
643
644 # 解析响应体为JSON
645 response_data = response.json()
646
647 friend_user_ids = [] # 用于存储符合条件的朋友的用户ID
648 if response_data.get("code") == 200:
649 friends_list = response_data.get("data", {}).get("list", [])
650 for friend in friends_list:
651 friend_user_id = friend.get("friend_user_id")
652 help_water_cnt = friend.get("help_water_cnt")
653 be_help_water_cnt = friend.get("friend_user_info", {}).get("be_help_water_cnt")
654 #print(f"朋友用户ID: {friend_user_id}, 帮忙浇水次数: {help_water_cnt}, 被帮忙浇水次数: {be_help_water_cnt}")
655
656 # 只有当帮忙浇水次数小于1时,才收集该朋友的用户ID
657 if help_water_cnt < 1:
658 friend_user_ids.append(friend_user_id)
659
660 return friend_user_ids # 返回所有符合条件收集到的用户ID
661 else:
662 print("请求失败,错误代码:", response_data.get("code"), "错误信息:", response_data.get("msg"))
663
664 except requests.exceptions.RequestException as e:
665 print(f"请求失败: {e}")
666
667
668

Callers 1

mainFunction · 0.85

Calls 3

create_headersFunction · 0.85
printFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected