Sending - Embedded
Sending an MMS while embedding the file directly in the POST message.
The embedded file must be base64 encoded, which is a simple process in most languages. PHP is simply:
$file_name = "file.jpg";
$file_data = base64_encode(file_get_contents("/tmp/".$file_name));
URL:
POST is required for this action
Argument | Required | Type |
source | yes | int |
destination | yes | int |
file_name | yes | string |
file_data | yes | string |
message | no | string |
shell
PHP+CURL
RESPONSE
Shell/CURL
base64image=$(base64 /tmp/file.jpg)
curl -v -X POST "https://api.teleapi.net/mms/send?token=XXXX" \
-d "source=13035551212&destination=13038884444&file_name=file.jpg&image=$base64image"
Using PHP+CURL
<?php
$file_name = "file.jpg";
$directory = "/tmp/";
$file_data = file_get_contents($directory.$file_name);
$data = array("source" => "13035551212",
"destination" => "13038884444",
"file_name" => $file_name,
"file_data" => base64_encode($file_data)
);
$data = http_build_query($data);
$baseurl = "https://api.teleapi.net/mms/send?token=XXXX";
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$retval = curl_exec($ch);
curl_close($ch);
$object = json_decode($retval);
print_r($object);
Last modified 2yr ago