2.4.0
增加 移除好友请求(新) http://doc.gzntkj.com/web/#/22?page_id=1707 增加 添加好友请求(新) http://doc.gzntkj.com/web/#/22?page_id=1761 增加 取消添加请求(新) http://doc.gzntkj.com/web/#/22?page_id=1763
正在显示
2 个修改的文件
包含
99 行增加
和
26 行删除
| @@ -532,7 +532,7 @@ class FacebookClient(Client): | @@ -532,7 +532,7 @@ class FacebookClient(Client): | ||
| 532 | variables = {"input": {"people_you_may_know_id": fbid, | 532 | variables = {"input": {"people_you_may_know_id": fbid, |
| 533 | "people_you_may_know_location": "FRIENDS_CENTER", | 533 | "people_you_may_know_location": "FRIENDS_CENTER", |
| 534 | "actor_id": self.uid, | 534 | "actor_id": self.uid, |
| 535 | - "client_mutation_id": "2"}} | 535 | + "client_mutation_id": self.get_client_mutation_id()}} |
| 536 | self.graphql_api('FriendingCometPYMKBlacklistSuggestionMutation', '2882558265094181', variables) | 536 | self.graphql_api('FriendingCometPYMKBlacklistSuggestionMutation', '2882558265094181', variables) |
| 537 | return {"success": True} | 537 | return {"success": True} |
| 538 | 538 | ||
| @@ -1541,7 +1541,8 @@ class FacebookClient(Client): | @@ -1541,7 +1541,8 @@ class FacebookClient(Client): | ||
| 1541 | params = {"notif_category": type, "notif_medium": channel, "toggle_value": toggle} # OFF/ON | 1541 | params = {"notif_category": type, "notif_medium": channel, "toggle_value": toggle} # OFF/ON |
| 1542 | action = base64.b64encode(f'NotificationMediumToggleServerActionToken;{json.dumps(params)}'.encode()) | 1542 | action = base64.b64encode(f'NotificationMediumToggleServerActionToken;{json.dumps(params)}'.encode()) |
| 1543 | action = action.decode() | 1543 | action = action.decode() |
| 1544 | - mutation_id = "{}:{}".format(int(time.time() * 1000), random.randint(0, 4294967295) + 1) | 1544 | + # mutation_id = "{}:{}".format(int(time.time() * 1000), random.randint(0, 4294967295) + 1) |
| 1545 | + mutation_id = self.get_client_mutation_id() | ||
| 1545 | variables = {"input": { | 1546 | variables = {"input": { |
| 1546 | "client_mutation_id": mutation_id, "actor_id": self.uid, | 1547 | "client_mutation_id": mutation_id, "actor_id": self.uid, |
| 1547 | "action_type": action, | 1548 | "action_type": action, |
| @@ -1626,6 +1627,74 @@ class FacebookClient(Client): | @@ -1626,6 +1627,74 @@ class FacebookClient(Client): | ||
| 1626 | j = self._payload_post("/ajax/add_friend/action.php?dpr=1", data) | 1627 | j = self._payload_post("/ajax/add_friend/action.php?dpr=1", data) |
| 1627 | return j | 1628 | return j |
| 1628 | 1629 | ||
| 1630 | + def FriendingCometFriendRequestConfirmMutation(self, friend_requester_id, source): | ||
| 1631 | + """同意好友请求""" | ||
| 1632 | + #TODO:source 多种未抓,文档 | ||
| 1633 | + var = {"input": {"cancelled_friend_requestee_id": friend_requester_id, "source": source, "actor_id": self.uid, | ||
| 1634 | + "client_mutation_id": self.get_client_mutation_id()}, "scale": 2} | ||
| 1635 | + res = self.graphql_api('FriendingCometFriendRequestCancelMutation', '3226051994092510', var) | ||
| 1636 | + try: | ||
| 1637 | + return {'success': True, 'data': res['data']} | ||
| 1638 | + except: | ||
| 1639 | + return {'success': False, "data": []} | ||
| 1640 | + | ||
| 1641 | + def FriendingCometFriendRequestDeleteMutation(self, friend_requester_id, source): | ||
| 1642 | + """移除好友请求""" | ||
| 1643 | + # FRIENDS_CENTER 朋友推荐列表处 | ||
| 1644 | + # pymk_timeline_chain 好友的好友位置取消 | ||
| 1645 | + # NETEGO 个人主页 | ||
| 1646 | + var = { | ||
| 1647 | + "input": {"people_you_may_know_id": friend_requester_id, "people_you_may_know_location": source, | ||
| 1648 | + "actor_id": self.uid, "client_mutation_id": self.get_client_mutation_id()}} | ||
| 1649 | + res = self.graphql_api('FriendingCometFriendRequestDeleteMutation', '2882558265094181', var) | ||
| 1650 | + try: | ||
| 1651 | + return {'success': True, 'data': res['data']} | ||
| 1652 | + except: | ||
| 1653 | + return {'success': False, "data": []} | ||
| 1654 | + | ||
| 1655 | + def FriendingCometFriendRequestCancelMutation(self, friend_requester_id, source): | ||
| 1656 | + """取消好友请求""" | ||
| 1657 | + # pymk 朋友推荐列表处 | ||
| 1658 | + # manage_outgoing_requests 查看已发出请求列表 | ||
| 1659 | + # profile 主页位置取消 | ||
| 1660 | + # pymk_timeline_chain 好友的好友位置取消 | ||
| 1661 | + # pymk_feed 自己主页推荐好友处取消 | ||
| 1662 | + # groups_member_list 公开小组成员 | ||
| 1663 | + # search 搜索好友取消 | ||
| 1664 | + var = {"input": {"cancelled_friend_requestee_id": friend_requester_id, "source": source, | ||
| 1665 | + "actor_id": self.uid, "client_mutation_id": self.get_client_mutation_id()}, | ||
| 1666 | + "scale": 2} | ||
| 1667 | + res = self.graphql_api('FriendingCometFriendRequestCancelMutation', '3226051994092510', var) | ||
| 1668 | + try: | ||
| 1669 | + return {'success': True, 'data': res['data']} | ||
| 1670 | + except: | ||
| 1671 | + return {'success': False, "data": []} | ||
| 1672 | + | ||
| 1673 | + def FriendingCometFriendRequestSendMutation(self, friend_requester_id, source): | ||
| 1674 | + """添加好友请求""" | ||
| 1675 | + # people_you_may_know 可能认识的人 | ||
| 1676 | + # profile_button 主页添加按钮 | ||
| 1677 | + # pymk_timeline_chain 好友的好友 | ||
| 1678 | + # groups_member_list 公开小组成员 | ||
| 1679 | + # search 搜索添加 | ||
| 1680 | + # netego_pymk 自己主页推荐好友添加 | ||
| 1681 | + source_list = { | ||
| 1682 | + 'people_you_may_know': 'friends_center', | ||
| 1683 | + 'netego_pymk': 'netego', | ||
| 1684 | + 'pymk_timeline_chain': 'pymk_timeline_chain' | ||
| 1685 | + } | ||
| 1686 | + var = { | ||
| 1687 | + "input": {"friend_requestee_ids": [friend_requester_id], | ||
| 1688 | + "refs": [None], "source": source, "actor_id": self.uid, | ||
| 1689 | + "client_mutation_id": self.get_client_mutation_id()}, "scale": 2} | ||
| 1690 | + if source in source_list.keys(): | ||
| 1691 | + var['input']['people_you_may_know_location'] = source_list[source] | ||
| 1692 | + res = self.graphql_api('FriendingCometFriendRequestSendMutation', '4391497287589685', var) | ||
| 1693 | + try: | ||
| 1694 | + return {'success': True, 'data': res['data']} | ||
| 1695 | + except: | ||
| 1696 | + return {'success': False, "data": []} | ||
| 1697 | + | ||
| 1629 | def primaryLocation(self): | 1698 | def primaryLocation(self): |
| 1630 | res = self._state._session.get('https://www.facebook.com/primary_location/info/') | 1699 | res = self._state._session.get('https://www.facebook.com/primary_location/info/') |
| 1631 | return parse_html.get_location_info(res.text) | 1700 | return parse_html.get_location_info(res.text) |
| @@ -1697,7 +1766,7 @@ class FacebookClient(Client): | @@ -1697,7 +1766,7 @@ class FacebookClient(Client): | ||
| 1697 | def feedbackActions(self, photo_id, action='like', flag=True): | 1766 | def feedbackActions(self, photo_id, action='like', flag=True): |
| 1698 | feedback = 'feedback:%s' % photo_id | 1767 | feedback = 'feedback:%s' % photo_id |
| 1699 | try: | 1768 | try: |
| 1700 | - variables = {"input": {"client_mutation_id": '2', "actor_id": self.uid, | 1769 | + variables = {"input": {"client_mutation_id": self.get_client_mutation_id(), "actor_id": self.uid, |
| 1701 | "feedback_id": base64.b64encode(feedback.encode()).decode(), | 1770 | "feedback_id": base64.b64encode(feedback.encode()).decode(), |
| 1702 | "feedback_reaction": 1, | 1771 | "feedback_reaction": 1, |
| 1703 | "feedback_source": "PHOTOS_SNOWLIFT", | 1772 | "feedback_source": "PHOTOS_SNOWLIFT", |
| @@ -1762,7 +1831,7 @@ class FacebookClient(Client): | @@ -1762,7 +1831,7 @@ class FacebookClient(Client): | ||
| 1762 | def answersQuestions(self, group_id, answers: list, accept_rules=True): | 1831 | def answersQuestions(self, group_id, answers: list, accept_rules=True): |
| 1763 | if isinstance(answers, str) and '[' in answers: | 1832 | if isinstance(answers, str) and '[' in answers: |
| 1764 | answers = json.loads(answers) | 1833 | answers = json.loads(answers) |
| 1765 | - var = {"input": {"client_mutation_id": "1", "actor_id": self.uid, | 1834 | + var = {"input": {"client_mutation_id": self.get_client_mutation_id(), "actor_id": self.uid, |
| 1766 | "group_id": group_id, "answers": answers, | 1835 | "group_id": group_id, "answers": answers, |
| 1767 | }} | 1836 | }} |
| 1768 | if accept_rules: | 1837 | if accept_rules: |
| @@ -2012,7 +2081,7 @@ class FacebookClient(Client): | @@ -2012,7 +2081,7 @@ class FacebookClient(Client): | ||
| 2012 | for x in story_actions: | 2081 | for x in story_actions: |
| 2013 | x['story_location'] = 'TIMELINE' | 2082 | x['story_location'] = 'TIMELINE' |
| 2014 | data = {"input": { | 2083 | data = {"input": { |
| 2015 | - "client_mutation_id": "1", | 2084 | + "client_mutation_id": self.get_client_mutation_id(), |
| 2016 | "actor_id": self.uid, | 2085 | "actor_id": self.uid, |
| 2017 | "story_actions": story_actions | 2086 | "story_actions": story_actions |
| 2018 | }} | 2087 | }} |
| @@ -2047,27 +2116,24 @@ class FacebookClient(Client): | @@ -2047,27 +2116,24 @@ class FacebookClient(Client): | ||
| 2047 | except Exception as e: | 2116 | except Exception as e: |
| 2048 | return {'success': False, 'errors': str(e)} | 2117 | return {'success': False, 'errors': str(e)} |
| 2049 | 2118 | ||
| 2050 | - def delete_dialog(self, pic_id, set_id): | 2119 | + def CometMediaViewerPhotoDeleteActionMutation(self, photo_id): |
| 2051 | """ | 2120 | """ |
| 2052 | 删除照片 | 2121 | 删除照片 |
| 2053 | """ | 2122 | """ |
| 2054 | - data = { | ||
| 2055 | - 'fbid': pic_id, | ||
| 2056 | - 'version': '9', | ||
| 2057 | - 'set': set_id, | ||
| 2058 | - 'next': '3143051995809753', | ||
| 2059 | - 'dpr': '2', | ||
| 2060 | - 'fb_dtsg': self._state.fb_dtsg_ag, | ||
| 2061 | - 'jazoest': self._state.jazoest, | ||
| 2062 | - 'confirmed': 1 | ||
| 2063 | - } | ||
| 2064 | - | ||
| 2065 | - url = '/ajax/photos/photo/delete/dialog.php' | 2123 | + variables = {"feedLocation": "COMET_MEDIA_VIEWER", |
| 2124 | + "input": {"photo_id": photo_id, "actor_id": self.uid, | ||
| 2125 | + "client_mutation_id": self.get_client_mutation_id()}, "isProfilePic": False, "scale": 2, | ||
| 2126 | + "renderLocation": None, | ||
| 2127 | + "privacySelectorRenderLocation": "COMET_MEDIA_VIEWER", "useDefaultActor": False} | ||
| 2066 | try: | 2128 | try: |
| 2067 | - res = self._post(url, data) | ||
| 2068 | - return {"success": True} | ||
| 2069 | - except: | ||
| 2070 | - return {"success": False} | 2129 | + res = self.graphql_api('CometMediaViewerPhotoDeleteActionMutation', '3292223457513194', |
| 2130 | + variables) | ||
| 2131 | + if 'errors' in res: | ||
| 2132 | + return {'success': False, 'errors': res['errors']} | ||
| 2133 | + else: | ||
| 2134 | + return {'success': True, 'data': res['data']} | ||
| 2135 | + except Exception as e: | ||
| 2136 | + return {'success': False, 'errors': str(e)} | ||
| 2071 | 2137 | ||
| 2072 | ###############graph接口 start ############## | 2138 | ###############graph接口 start ############## |
| 2073 | 2139 | ||
| @@ -2409,6 +2475,13 @@ class FacebookClient(Client): | @@ -2409,6 +2475,13 @@ class FacebookClient(Client): | ||
| 2409 | def onWebNotice(self, kwargs): | 2475 | def onWebNotice(self, kwargs): |
| 2410 | print(kwargs) | 2476 | print(kwargs) |
| 2411 | 2477 | ||
| 2478 | + def get_client_mutation_id(self): | ||
| 2479 | + key = f'{self.uid}:client_mutation_id' | ||
| 2480 | + client_mutation_id = cache.get(key=key, default=0) | ||
| 2481 | + result = client_mutation_id + 1 | ||
| 2482 | + cache.set(key=key, value=client_mutation_id + 1, ttl=24 * 60 * 60) | ||
| 2483 | + return str(result) | ||
| 2484 | + | ||
| 2412 | def graphql_api(self, friendly_name, doc_id, variables: dict, is_mutli_json=False): | 2485 | def graphql_api(self, friendly_name, doc_id, variables: dict, is_mutli_json=False): |
| 2413 | data = { | 2486 | data = { |
| 2414 | 'av': self.uid, | 2487 | 'av': self.uid, |
| @@ -2588,7 +2661,7 @@ class FacebookClient(Client): | @@ -2588,7 +2661,7 @@ class FacebookClient(Client): | ||
| 2588 | 2661 | ||
| 2589 | def playGame(self, game_id): | 2662 | def playGame(self, game_id): |
| 2590 | payload = { | 2663 | payload = { |
| 2591 | - "input": {"client_mutation_id": f"{int(time.time() * 1000)}:{random.randint(1000000000, 9000000000)}", | 2664 | + "input": {"client_mutation_id": self.get_client_mutation_id(), |
| 2592 | "actor_id": self.uid, | 2665 | "actor_id": self.uid, |
| 2593 | "app_id": game_id, | 2666 | "app_id": game_id, |
| 2594 | "grant_permissions": ["PUBLIC_INFO", "CONNECTED_PLAYERS", "FRIENDS_CAN_SEE", | 2667 | "grant_permissions": ["PUBLIC_INFO", "CONNECTED_PLAYERS", "FRIENDS_CAN_SEE", |
| @@ -2596,7 +2669,7 @@ class FacebookClient(Client): | @@ -2596,7 +2669,7 @@ class FacebookClient(Client): | ||
| 2596 | "enable_global_tos": False}} | 2669 | "enable_global_tos": False}} |
| 2597 | self.graphql_api('InstantGamesRelayPermissions_GrantPermissionsMutation', '1405747992825083', payload) | 2670 | self.graphql_api('InstantGamesRelayPermissions_GrantPermissionsMutation', '1405747992825083', payload) |
| 2598 | payload = { | 2671 | payload = { |
| 2599 | - "input": {"client_mutation_id": f"{int(time.time() * 1000)}:{random.randint(1000000000, 9000000000)}", | 2672 | + "input": {"client_mutation_id": self.get_client_mutation_id(), |
| 2600 | "actor_id": self.uid, | 2673 | "actor_id": self.uid, |
| 2601 | "game_id": game_id, "request": "QE_PARAM_NO_EXPOSURE_FETCH", | 2674 | "game_id": game_id, "request": "QE_PARAM_NO_EXPOSURE_FETCH", |
| 2602 | "session_id": common.random_uuid(), "sdk_version": "6.3", "data": "{}"}} | 2675 | "session_id": common.random_uuid(), "sdk_version": "6.3", "data": "{}"}} |
-
请 注册 或 登录 后发表评论