0
votes

Trying to test Twilio to migrate from Tropo, We alreaddy installed the libraries and tested sucessfully quickstart example https://www.twilio.com/docs/voice/quickstart/php. But got stuck trying to do a call and play a mp3 file.

Having next PHP function:

public function call_twilioAction(){
        $account_sid = '******************************';
        $auth_token = '*****************************';
        $twilio_number = "NUMBER";

        // call  to my office
        $to_number = "NUMBER";

        $client = new Client($account_sid, $auth_token);
        $client->account->calls->create(  
            $to_number,
            $twilio_number,
            array(
                "url" => "https://arantec.smartyplanet.com/twilo/voice.xml"
        );
        return $this->render('::base.json.twig', array("data" => array()));
    }

And inside the voice.xml file:

<Response>
  <Play>https://arantec.smartyplanet.com/twilo/Smartyalert_es.mp3</Play>
</Response>

As you can check, both files (xml, mp3) are accessible from internet, and are in the same called function host, where is the problem?

Still getting the error:

Twilio\Exceptions\EnvironmentException:  (uncaught exception) at Twilio/Http/CurlClient.php line 41

Thank you!!

1
I assume all NUMBER values are just placeholders and you have valid phone numbers there?Cody Caughlan
Yes, phone numbers are there and work doing the quickstart example.NorthmaN
Seems silly but maybe Twilio really wants your XML responses to contain the XML preamble <?xml version="1.0" encoding="UTF-8"?>Cody Caughlan
It doesn't work. Thanks @Cody Caughlan.NorthmaN
Code works in my localhost, not in the server. I guess is a Curl problem. I don't know if cause is using a twilio trial accout.NorthmaN

1 Answers

0
votes

So!! Finally I found out the problem in server side. As our server is ssl-secured we had to modify /Twilio/Http/CurlClient.php addind next line to access to a non ssl-secured server.

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

Thanks everybody!