Method: POST
Endpoint: /api/addBroadcast
Parameter | Type | Required |
Description |
group_name | string | Yes | Sort this broadcast in specific group |
broadcast_name | string | Yes | Name your broadcast |
email_subject | string | Yes | Email subject of this broadcast |
content_html | string | Yes | HTML content for the broadcast |
content_text | string | Yes | TEXT version of the broadcast |
response | 0, 1 (default: 0) | No | Get full response of the operation |
Parameter | Type | Description |
status | JSON | Success or Error |
result | JSON | Result of the operation |
response | JSON | Output of the operation |
<?php
// Authentication
$api_token = 'API_KEY'; // Mumara API Key (can be found in Settings -> API Key)
$domain = 'http://www.anydomain.com'; // Your Mumara Domain Name
// API Endpoint
$endpoint = '/api/addBroadcast';
//parameters
$params = [
'broadcast_name' => 'Test Broadcast',
'group_name' => 'Test Group',
'email_subject' => 'Big Discount Offer',
'content_html' => '<p>Rush to the stores and get 50% discount on your next purchase.</p>',
'content_text' => 'Rush to the stores and get 50% discount on your next purchase',
'response' => 1,
];
// Defining cURL Request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$domain.$endpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_HTTPHEADER,
array('Content-Type: application/json', 'Authorization: Bearer ' . $api_token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Executing cURL
$output = curl_exec ($ch);
// Printing Output
echo "<pre>";
echo json_encode(json_decode($output),JSON_PRETTY_PRINT );
// Closing cURL
curl_close ($ch);
?>
{
"status": "success",
"result": "Success: Broadcast successfully created.",
"response": {
"id": 8,
"name": "Test Broadcast",
"subject": "Big Discount Offer",
"group_id": 9,
"content_html": "<p>Rush to the stores and get 50% discount on your next purchase.</p>",
"content_text": "Rush to the stores and get 50% discount on your next purchase",
"user_id": 2,
"created_at": "2019-05-14 10:59:37",
"updated_at": "2019-05-14 10:59:37"
}
}
{
"status": "error",
"result": {
"broadcast_name": [
"Error: Missing required parameter, broadcast name"
]
}
}