Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added remove friend #298

Merged
merged 9 commits into from
Jun 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion fbchat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
from .models import *
from .graphql import *
import time

try:
from urllib.parse import urlparse, parse_qs
except ImportError:
from urlparse import urlparse, parse_qs


class Client(object):
Expand Down Expand Up @@ -1313,6 +1316,25 @@ def friendConnect(self, friend_id):
r = self._post(self.req_url.CONNECT, data)
return r.ok

def removeFriend(self, friend_id=None):
"""Removes a specifed friend from your friend list

:param friend_id: The id of the friend that you want to remove
:return: Returns error if the removing was unsuccessful, returns True when successful.
"""
payload = {
"friend_id": friend_id,
"unref": "none",
"confirm": "Confirm",
}
r = self._post(self.req_url.REMOVE_FRIEND, payload)
query = parse_qs(urlparse(r.url).query)
if "err" not in query:
log.debug("Remove was successful!")
return True
else:
log.warning("Error while removing friend")
return False

"""
LISTEN METHODS
Expand Down
3 changes: 2 additions & 1 deletion fbchat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ class ReqUrl(object):
ATTACHMENT_PHOTO = "https://www.facebook.com/mercury/attachments/photo/"
EVENT_REMINDER = "https://www.facebook.com/ajax/eventreminder/create"
MODERN_SETTINGS_MENU = "https://www.facebook.com/bluebar/modern_settings_menu/"

REMOVE_FRIEND = "https://m.facebook.com/a/removefriend.php"

pull_channel = 0

def change_pull_channel(self, channel=None):
Expand Down