mercredi 31 mai 2017

Formatting XML for Twilio Response

I am attempting to receive a fax in my Laravel app, but I can't seem to format the XML properly.

Since I am just setting this up for the first time, I tried to emulate the basic how-to in the Twilio Quickstart guide.

Using the Twilio dashboard, I have set a webhook address of myapp.com/fax/sent to be notified when an incoming fax is attempting to be sent:

public function sent()
{
    $twimlResponse = new SimpleXMLElement("<Response></Response>");
    $recieveEl = $twimlResponse->addChild('Receive');
    $receiveEl->addAttribute('action', '/fax/received');

    return response($twimlResponse->asXML())
           ->header('Content-Type', 'text/xml');
}

The error that I get from Twilio is essentially empty:

Error 12100 Document parse failure

The Twilio error request inspector shows no head or body.

I have also tried to return a hard-coded view file in place of building the xml:

view fax.sent:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
   <Receive action="/fax/received" />
</Response>

and then changed the sent function to:

public function sent()
   {
      return View::make('fax.sent')->header('Content-Type', 'text/xml');
   }

This returns the same error message.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire