Overview
Telecom Lookup Tools
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...
1
<?php
2
//setup token
3
$token = 'your token';
4
โ€‹
5
//setup the path to the files we want to send
6
$files = array(
7
'/path/to/file1',
8
'/path/to/file2'
9
);
10
โ€‹
11
//a very simple function you can copy/paste if you want
12
function send_fax($did_id, $destination, $recipient_name, $files) {
13
global $token;
14
//get the data and base64 the files
15
foreach ($files as $i => $file) {
16
$files[$i] = base64_encode(file_get_contents($file));
17
}
18
$data = array(
19
'token' => $token,
20
'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
21
'destination' => $destination,
22
'recipient' => $recipient,
23
'files' => json_encode($files)
24
);
25
$data = http_build_query($data);
26
$ch = curl_init('https://apiv1.teleapi.net/fax/send');
27
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
28
curl_setopt($ch, CURLOPT_POST, 1);
29
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
30
$resp = curl_exec($ch);
31
return json_decode($resp);
32
}
33
โ€‹
34
//code that actually sends a fax -- provided you pass a real did_id and destination number. and file(s).
35
$resp = send_fax(555, 5555555555, 'Bobby Tables', $files);
36
if ($resp->code == 200) {
37
die("Successfully sent fax\n");
38
}
39
die("Could not send fax: " . print_r($resp, true));
Copied!
Copy link