Link to home
Start Free TrialLog in
Avatar of Kevin Brennan
Kevin Brennan

asked on

Getting Twilio fax receive to work with classic ASP

I have a Twilio account and have created sending functions for SMS and FAX using classic asp.  

I am trying to construct a way to get an incoming fax and log its file location using twiml and classic asp.

Twilio server comes to my server to get the OK to answer call, then receives the fax and returns the mediaurl of the fax file,  I need to be able to do these 2 steps.  I have tried with PHP but cannot get it to work.  Since the rest of the site is written in Classic asp and I can already send notifications from my software and I can also send FAX from my software just the receiving is the problem.

Any suggestions from the experts??

Thanks

Kevin

Here is a link to the site with basic code

https://www.twilio.com/docs/fax/receive

.
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Hi Kevin,

How about setting up a simple page say : FaxHandler.asp and then request the http header? Also, you will have to allow CORS request from Twilio source servers.

dim url
url = Request.ServerVariables["HTTP_MediaUrl"])
'log url

Open in new window


PS:May I know why use Classic ASP? Is it an absolute requirement or you can move/use any of the modern frameworks?

Regards,
Chinmay.
Avatar of Kevin Brennan
Kevin Brennan

ASKER

I was using Classic ASP because the rest of the site is written in it.  I tried to get the PHP to work with codeignitor but did not.

I have to issue the command to receive or reject the fax and then once it is received to get the fax url, copy to local server and enter info into sql for customer to see.  the only problem that I have been having is getting Twilio to webhook to my server to initiate the receive.

As I stated, I have made the sending of FAX and SMS available through classic asp.  Cannot figure why I cannot get the receive fax to work correctly.

Thanks
Hi Kevin,

Understood. Please give it a try. Create a simple asp page (as if you were building a page with Form) and use Request.ServerVariables["HTTP_MediaUrl"] to gain access to posted data.

Regards,
Chinmay.
well I have to tell Twilio to receive the fax first.  that is where the problem comes in.
Anyone else have any ideas??

I am trying to convert this

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class FaxController extends Controller {

    public function __construct()
    {
        parent::__construct();

        // set content-type for all requests returned by this controller
        $this->set_output->set_content_type('text/xml');
    }

    // Define a handler for when the fax is initially sent
    public function sent()
    {
        $twimlResponse = new SimpleXMLElement("<Response></Response>");
        $receiveEl = $twimlResponse->addChild('Receive');
        $receiveEl->addAttribute('action', '/fax/received');

        $this->output->set_output($twimlResponse->asXML());
    }

    // Define a handler for when the fax is finished sending to us - if successful,
    // We will have a URL to the contents of the fax at this point
    public function received()
    {
        // log the URL of the PDF received in the fax
        log_message('info', $this->input->post("MediaUrl"));

        // Respond with empty 200/OK to Twilio
        $this->set_status_header(200);
        $this->output->set_output('');
    }
}

to something that I can use with classic asp
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.