Send an MMS with Cellcast API

Estimated reading: 3 minutes 526 views

Base URL

https://cellcast.com.au/api/v3/send-mms

Method: POST (Form data)

Parameters

Header ParametersDescription 
APPKEYPlease add provided APPKEY – linked to your Cellcast account 
Content-Typeapplication/json 

MMS Data Parameters

NameExampleDescription
subjectMMS subject goes herestring – Optional field
mms_textMMS text goes herestring – Required field
– To add a new line to the message, use “rn” in the message string with only double quote
mms_fileMMS Image file goes hereOnly 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

CodeStatusDescription
200SUCCESS

“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

StatusCodeDescription
AUTH_FAILED_NO_DATA401You have not provided APPKEY
AUTH_FAILED401– APPKEY you have provided is invalid
– You are not a registered user
FIELD_EMPTY400Required field is empty
RECIPIENTS_ERROR400No valid recipients left after validation or recipient in unsubscribed list.
FIELD_INVALID400-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_REQUEST400Please 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: <<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 = '<<VALID IMAGE URL>>';
$numbers = array("<<Number1>>","<<Number2>>","<<Number3>>");

//Call function to send MMS
sendMms($subject,$mms_text,$mms_file,$numbers);