steampy
steampy copied to clipboard
Methods for adding and removing friends from friend list
Methods for adding and removing friends from friend list
Hello! I'm not a programmer, but this works: def friend_add(self, steamid: str) -> dict: url = 'https://steamcommunity.com/actions/AddFriendAjax' data = f"sessionID={self._get_session_id()}&steamid={steamid}&accept_invite=0" headers = { "Host": "steamcommunity.com", "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0", "Accept": "/", "Accept-Language": "en-US,en;q=0.5", "Accept-Encoding": "gzip, deflate, br", "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "X-Requested-With": "XMLHttpRequest", "Content-Length": str(len(str(data))), "Origin": "https://steamcommunity.com", "Connection": "keep-alive", #"Cookie": "".join(f"{cookie.key}={cookie.value}; " # for key, cookie in self.session.cookie_jar.filter_cookies(self.StoreURL).items())[:-2], "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-origin", "Sec-GPC": "1" } response = self._session.post(url, data=data,headers=headers).json() return response def friend_remove(self, steamid: str) -> dict: url = 'https://steamcommunity.com/actions/RemoveFriendAjax' data = f"sessionID={self._get_session_id()}&steamid={steamid}&accept_invite=0" headers = { "Host": "steamcommunity.com", "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0", "Accept": "/", "Accept-Language": "en-US,en;q=0.5", "Accept-Encoding": "gzip, deflate, br", "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "X-Requested-With": "XMLHttpRequest", "Content-Length": str(len(str(data))), "Origin": "https://steamcommunity.com", "Connection": "keep-alive", #"Cookie": "".join(f"{cookie.key}={cookie.value}; " # for key, cookie in self.session.cookie_jar.filter_cookies(self.StoreURL).items())[:-2], "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-origin", "Sec-GPC": "1" } response = self._session.post(url, data=data,headers=headers).json() return response
Does AddFriendAjax still work? I tried the same method as above, but it doesn't work for me.
This feature works for me, this is how I added this method to client.py. You can send the response received from this function.
Yeah, ur implementation work for me. Ааfter some research, can say that the data for this methods must be passed in the body of request (not like query parameters), also Content-Type
header required.