Facebook Client

Facebook Client handles all Facebook related actions.

class fbchat_muqit.FacebookClient

Bases: object

FacebookClient handles facebook posts, reaction, friend request etc. and for publishing post, commenting and reacting to Facebook posts.

__init__(*args, **kwargs) None
async cancel_friend_request(user_id: str)

Cancel a friend request that you sent using the requested to user Id.

Parameters:

user_id (str) – The Id of the User you sent friend request to.

get_mutation_id() str
async manage_friend_request(user_id: str, accept_request: bool = True)

Manage friend requests accept or reject a friend requests

Parameters:
  • user_id (str) – The user’s id you want to accept or reject the friend requests.

  • accept_request (bool) – Accepts the friend request if true else rejects it.

async publish_post(text: str, image_paths: List[str] | None = None, video_paths: List[str] | None = None, tag_users: List[str] | None = None, specific_users: List[str] | None = None, except_users: List[str] | None = None, audience: Audience = Audience.PUBLIC, mentions: List[Mention] | None = None) str

Publish a post in facebook.

Parameters:
  • text (str) – The text message you want to add in the post.

  • image_paths (Optional[str]) – The Images you want to attach to the post.

  • video_paths (Optional[List[str]]) – The video to attach to the post.

  • tag_users (Optional[str]) – Tag users to the postu using their uid.

  • specific_users (Optional[str]) – only show the post to specific users.

  • except_users (Optional[str]) – Show the post except some users using their uid.

  • audience (Audience) – The audience of the post can be FRIENDS, EVERYONE, ONLYME.

  • mentions (Optional[List[Mention]]) – The users you want to mention in the post.

Returns:

If successfully published the post returns post’s feedback Id (base64 encoded post id) or post Id.

Return type:

str

async react_to_post(feedback_id: str | None = None, post_id: int | None = None, reaction: FBReaction = FBReaction.LOVE)

React to a post using post’s feedback Id or Post Id

Parameters:
  • feedback_id (Optional[str]) – The feedback Id of the post to react.

  • post_id (Optional[int]) – The Id of post to react. (feedback_id or post_id one of them must be provided)

  • reaction (FBReaction) – The reaction to react with (LOVE, HAHA, SAD e.g.)

async send_friend_request(user_ids: List[str])

Send friend request to one or multiple users using their Id.

Parameters:

user_ids (List[str]) – A list of user ids to send friend request.

async unfriend(user_id: str)

Unfriend a friend using their Id.

Parameters:

user_id (str) – Id of the User to unfriend.

async upload_photo(image_path: str) str

Upload a photo to Facebook and return the photo ID.

Parameters:

image_path (str) – Path to the image file to upload

Returns:

Upload response containing photoID

Return type:

str

async upload_photos(image_paths: List[str], max_concurrent: int = 5) List[str]

Upload multiple photos concurrently and return list of photo IDs.

Parameters:
  • image_paths (List[str]) – List of image file paths to upload

  • max_concurrent (int) – Maximum number of concurrent uploads (default: 5)

Returns:

List of successfully uploaded photo IDs (preserves order)

Return type:

List[str]

Overview

This FacebookClient is seperated from the Messenger Client. FacebookClient is not used directly instead used as a base class for the main Client class for maintainabilty.