Yep, you read the title correctly and it says “fax.” Faxes are still used more than I thought, and it is really cool that Twilio has an API to send and receive faxes that is quite easy to use.
Today in this post I will be talking about sending faxes from your Drupal website. Which is quite easy and doesn’t take much code to achieve.
I have pulled together a code example from the Twilio API documents and as you can see below there isn’t much there.
$twilio = new Client($sid, $token);
$to = “+1234567890”;
$from = “+0987654321”;
$document = “https://example.com/document.pdf”;
$response = twilio->fax->v1->faxes->create($to, $document,["from" => $from]);
A couple of notes on the Twilio fax API:
- There isn’t much of a response back which can make error handling or logging a little difficult.
- The document being faxed must be a PDF.
- Twilio: https://www.twilio.com/fax