Send an MMS with Cellcast API
Estimated reading: 3 minutes
692 views
Base URL
https://cellcast.com.au/api/v3/send-mms
Method: POST (Form data)
Parameters
Header Parameters | Description | |
---|---|---|
APPKEY | Please add provided APPKEY – linked to your Cellcast account | |
Content-Type | application/json |
MMS Data Parameters
Name | Example | Description |
---|---|---|
subject | MMS subject goes here | string – Optional field |
mms_text | MMS text goes here | string – Required field – To add a new line to the message, use “rn” in the message string with only double quote |
mms_file | MMS Image file goes here | Only PNG, GIF and JPEG are allowed and Max Image size 380KB. – Please upload size 300x450px – Required field |
numbers | [“+61400000000”] | JSON encoded Array – Required field For multiple MMS send: [“+61400000000″,”+61400000001”] You can pass 1000 numbers to send an MMS in one API call – Required field |
Successful Responses
Code | Status | Description |
---|---|---|
200 | SUCCESS | “You will get MMS scheduled count and credit deduction count. |
Successful Responses look like
{
"meta": {
"code": 200,
"status": "SUCCESS"
},
"msg": "Queued",
"data": {
"messages": [
{
"message_id": "A21741CB-9B8E-3956-A1CE-NNNNNNNNNN",
"to": "+614NNNNNNNN",
"subject": "MMS subject here",
"body": "MMS body here",
"date": "2019-06-24 21:24:32",
"direction": "out"
}
],
"total_numbers": 2,
"success_number": "2",
"credits_used": "2"
}
}
Error Response
Status | Code | Description |
---|---|---|
AUTH_FAILED_NO_DATA | 401 | You have not provided APPKEY |
AUTH_FAILED | 401 | – APPKEY you have provided is invalid – You are not a registered user |
FIELD_EMPTY | 400 | Required field is empty |
RECIPIENTS_ERROR | 400 | No valid recipients left after validation or recipient in unsubscribed list. |
FIELD_INVALID | 400 | -You can pass 10000 numbers to send an MMS in one API call – You do not have enough credit to send MMS. – You can pass text up to 1000 characters to send an MMS. – You can pass the subject up to 40 characters to send an MMS. – Choose image file to upload. – Upload valid image. Only PNG, GIF and JPEG are allowed. – Image size exceeds 380KB – Problem in uploading image files. |
BAD_REQUEST | 400 | Please provide proper data |
Error Responses look like
{
"meta": {
"code": 400,
"status": "FIELD_INVALID"
},
"msg": "You can pass text up to 1000 characters to send an MMS.",
"data": []
}
PHP Code Example
You can call following function to send MMS.
function sendMms($subject, $mms_text, $mms_file, $phone_number) {
try {
$url = 'https://cellcast.com.au/api/v3/send-mms'; //API URL
$fields = array(
'subject' => $subject,
'mms_text' => $mms_text, //here goes your MMS text
'mms_file' => $mms_file,
'numbers' => $phone_number // Your numbers array goes here
);
$headers = array(
'APPKEY: <>',
'Accept: application/json',
'Content-Type: application/json',
);
$ch = curl_init(); //open connection
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if (!$result = curl_exec($ch)) {
$response_error = json_decode(curl_error($ch));
return json_encode(array("status" => 400, "msg" => "Something went to wrong, please try again", "result" => $response_error));
}
curl_close($ch);
return json_encode(array("status" => 200, "msg" => "MMS sent successfully", "result" => json_decode($result)));
} catch (\Exception $e) {
return json_encode(array("status" => 400, "msg" => "Something went to wrong, please try again.", "result" => array()));
}
}
Call Function
//Set value of MMS
$subject = 'Subject here';
$mms_text = 'MMS text here';
$mms_file = '<>';
$numbers = array("<>","<>","<>");
//Call function to send MMS
sendMms($subject,$mms_text,$mms_file,$numbers);