Skip to content

Instantly share code, notes, and snippets.

@seanlane
Created August 31, 2017 06:36
Show Gist options
  • Save seanlane/67504bf39696de8c0bc88ad89844f9df to your computer and use it in GitHub Desktop.
Save seanlane/67504bf39696de8c0bc88ad89844f9df to your computer and use it in GitHub Desktop.
Python Fax via Phaxios
#!/usr/bin/env python3
from subprocess import call
import sys
if len(sys.argv) <= 2:
print("Usage: send_fax NUMBER FILENAME...")
exit(-1)
number = sys.argv[1]
api_key = 'put_api_key_here'
api_secret = 'put_api_secret_here'
command_args = [
"curl",
"https://api.phaxio.com/v2/faxes",
"-u '{}:{}'".format(api_key, api_secret),
"-F 'to={}'".format(number)
]
for file in sys.argv[2:]:
command_args.append("-F 'file=@{}'".format(file))
call(' '.join(command_args), shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment