Skip to content

Instantly share code, notes, and snippets.

@dannycabrera
Created August 21, 2019 20:15
Show Gist options
  • Save dannycabrera/5a9107b8b9a25e05a87d62bedf14f2d6 to your computer and use it in GitHub Desktop.
Save dannycabrera/5a9107b8b9a25e05a87d62bedf14f2d6 to your computer and use it in GitHub Desktop.
FaxApp Program.cs
using Microsoft.Owin.Hosting;
using System;
using Twilio;
using Twilio.Rest.Fax.V1;
namespace FaxApp
{
class Program
{
static IDisposable _app = null;
static void Main(string[] args)
{
_app = WebApp.Start<Startup>(url: "http://192.168.1.100:9000/");
while (true)
{
Console.WriteLine("Enter command(s): ex. SendFax");
var input = Console.ReadLine();
if (input.ToLower() == "sendfax")
{
Console.WriteLine("Number to send fax to... ex. +19541112345");
var to = Console.ReadLine();
Console.WriteLine("File to send... ex. Fax.pdf");
var filename = Console.ReadLine();
var myRemoteAddress = "http://myExternalIPOrUrl:9000/faxapp/callback";
Console.WriteLine($"SendFax to: {to}...");
TwilioClient.Init("TwilioAccountSid", "TwilioAuthToken");
var fax = FaxResource.Create(
from: "Replace with your Twilio Fax Number",
to: to,
mediaUrl: new Uri($"{myRemoteAddress}/getfile?fileName={filename}"),
statusCallback: new Uri($"{myRemoteAddress}/status")
);
Console.WriteLine($"Sent Fax sid: {fax.Sid}, status: {fax.Status}");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment