راهنمای توسعهدهندگان برای اتصال به Output Messenger
Output Messenger یک REST API کامل ارائه میدهد که به شما امکان میدهد نرمافزارهای خود را با آن یکپارچه کنید. با استفاده از این API میتوانید:
تمام درخواستهای API باید با API Key احراز هویت شوند:
GET /api/v1/users
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
برای دریافت API Key:
# دریافت لیست کاربران
GET /api/v1/users
# ایجاد کاربر جدید
POST /api/v1/users
{
"username": "newuser",
"fullname": "New User",
"password": "securepassword",
"email": "user@example.com"
}
# بهروزرسانی کاربر
PUT /api/v1/users/{user_id}
# حذف کاربر
DELETE /api/v1/users/{user_id}
# ارسال پیام
POST /api/v1/messages
{
"recipient": "username",
"message": "Hello from API!",
"type": "text"
}
# دریافت تاریخچه چت
GET /api/v1/messages/{user_id}
# دریافت لیست گروهها
GET /api/v1/groups
# ایجاد گروه
POST /api/v1/groups
{
"name": "Development Team",
"members": ["user1", "user2", "user3"]
}
<?php
$api_key = 'YOUR_API_KEY';
$endpoint = 'https://your-server.com/api/v1/users';
$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $api_key,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
$users = json_decode($response, true);
print_r($users);
?>
const apiKey = 'YOUR_API_KEY';
const endpoint = 'https://your-server.com/api/v1/users';
fetch(endpoint, {
headers: {
'Authorization': 'Bearer ' + apiKey,
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
api_key = 'YOUR_API_KEY'
endpoint = 'https://your-server.com/api/v1/users'
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
response = requests.get(endpoint, headers=headers)
users = response.json()
print(users)