Send a Fax

/send
Full Url:
Arguments:
  • token (string, required)
  • did_id (int, required)
  • destination (phone number, required)
  • recipient (string, required)
  • files (JSON encoded array of the file data)
Info: This is sending a fax. For files itself, you can send more than one file (cover page, content, etc). We will put it all together and send it out. For this, we expect a JSON encoded array of the file data. I'll provide a bit of example PHP...
<?php
//setup token
$token = 'your token';
//setup the path to the files we want to send
$files = array(
'/path/to/file1',
'/path/to/file2'
);
//a very simple function you can copy/paste if you want
function send_fax($did_id, $destination, $recipient_name, $files) {
global $token;
//get the data and base64 the files
foreach ($files as $i => $file) {
$files[$i] = base64_encode(file_get_contents($file));
}
$data = array(
'token' => $token,
'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);
$resp = curl_exec($ch);
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));