Metadata-Version: 2.4
Name: fb-gapi
Version: 0.1.1
Summary: A lightweight Python SDK for sending messages via Facebook Messenger
Home-page: https://github.com/jayeeed/facebook-messenger-sdk
Author: Jayed
Author-email: jayedbinjahangir@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: requests
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary


# Facebook Messenger Graph API Python SDK

A lightweight Python SDK for sending messages (text and image attachments) using the Facebook Graph API.

## 🚀 Usage

### 1. Import the client

```python
from facebook_messenger import MessengerClient
```

### 2. Initialize with your Page Access Token

```python
client = MessengerClient(access_token="YOUR_PAGE_ACCESS_TOKEN")
```

---

## ✉️ Sending a Text Message

```python
response = client.send_text(recipient_id="USER_PSID", message_text="Hello, user!")
print(response)
```

---

## 🖼️ Sending an Image Attachment

```python
image_url = "https://example.com/image.jpg"
response = client.send_attachment(recipient_id="USER_PSID", image_url=image_url)
print(response)
```

---

## ⚠️ Error Handling

This SDK will raise a `MessengerAPIError` when the Facebook API responds with an error.

### Example:

```python
from facebook_messenger import MessengerAPIError

try:
    client.send_text("invalid_user_id", "Hi!")
except MessengerAPIError as e:
    print(f"Facebook API Error: {e}")
```

### Error Output Example:

```
MessengerAPIError (HTTP 400): [OAuthException] Invalid OAuth access token. (code 190)
```

---

## 📄 Requirements

- Python 3.6+
- `requests`

Install requirements using:

```bash
pip install -r requirements.txt
```

---

## 🛠️ TODO

- Add support for more attachment types (video, audio, file)
- Support for templates, quick replies, and buttons
- Webhook integration

---

## 📃 License

MIT License. Use freely and contribute!
