//setup the path to the files we want to send
//a very simple function you can copy/paste if you want
function send_fax($did_id, $destination, $recipient_name, $files) {
//get the data and base64 the files
foreach ($files as $i => $file) {
$files[$i] = base64_encode(file_get_contents($file));
'did_id' => $did_id, //I'll fix this so you can send source, but this is how I use it so it's already written this way
'destination' => $destination,
'recipient' => $recipient,
'files' => json_encode($files)
$data = http_build_query($data);
$ch = curl_init('https://apiv1.teleapi.net/fax/send');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
return json_decode($resp);
//code that actually sends a fax -- provided you pass a real did_id and destination number. and file(s).
$resp = send_fax(555, 5555555555, 'Bobby Tables', $files);
if ($resp->code == 200) {
die("Successfully sent fax\n");
die("Could not send fax: " . print_r($resp, true));