Twilio - Call and play mp3












0















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:



TwilioExceptionsEnvironmentException:  (uncaught exception) at Twilio/Http/CurlClient.php line 41


Thank you!!










share|improve this question























  • I assume all NUMBER values are just placeholders and you have valid phone numbers there?

    – Cody Caughlan
    Nov 27 '18 at 16:47











  • Yes, phone numbers are there and work doing the quickstart example.

    – Norman Morell Asensio
    Nov 27 '18 at 16:49






  • 1





    Seems silly but maybe Twilio really wants your XML responses to contain the XML preamble <?xml version="1.0" encoding="UTF-8"?>

    – Cody Caughlan
    Nov 27 '18 at 17:41











  • It doesn't work. Thanks @Cody Caughlan.

    – Norman Morell Asensio
    Nov 28 '18 at 8:48











  • 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.

    – Norman Morell Asensio
    Nov 28 '18 at 10:22
















0















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:



TwilioExceptionsEnvironmentException:  (uncaught exception) at Twilio/Http/CurlClient.php line 41


Thank you!!










share|improve this question























  • I assume all NUMBER values are just placeholders and you have valid phone numbers there?

    – Cody Caughlan
    Nov 27 '18 at 16:47











  • Yes, phone numbers are there and work doing the quickstart example.

    – Norman Morell Asensio
    Nov 27 '18 at 16:49






  • 1





    Seems silly but maybe Twilio really wants your XML responses to contain the XML preamble <?xml version="1.0" encoding="UTF-8"?>

    – Cody Caughlan
    Nov 27 '18 at 17:41











  • It doesn't work. Thanks @Cody Caughlan.

    – Norman Morell Asensio
    Nov 28 '18 at 8:48











  • 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.

    – Norman Morell Asensio
    Nov 28 '18 at 10:22














0












0








0








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:



TwilioExceptionsEnvironmentException:  (uncaught exception) at Twilio/Http/CurlClient.php line 41


Thank you!!










share|improve this question














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:



TwilioExceptionsEnvironmentException:  (uncaught exception) at Twilio/Http/CurlClient.php line 41


Thank you!!







twilio






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 27 '18 at 16:34









Norman Morell AsensioNorman Morell Asensio

236




236













  • I assume all NUMBER values are just placeholders and you have valid phone numbers there?

    – Cody Caughlan
    Nov 27 '18 at 16:47











  • Yes, phone numbers are there and work doing the quickstart example.

    – Norman Morell Asensio
    Nov 27 '18 at 16:49






  • 1





    Seems silly but maybe Twilio really wants your XML responses to contain the XML preamble <?xml version="1.0" encoding="UTF-8"?>

    – Cody Caughlan
    Nov 27 '18 at 17:41











  • It doesn't work. Thanks @Cody Caughlan.

    – Norman Morell Asensio
    Nov 28 '18 at 8:48











  • 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.

    – Norman Morell Asensio
    Nov 28 '18 at 10:22



















  • I assume all NUMBER values are just placeholders and you have valid phone numbers there?

    – Cody Caughlan
    Nov 27 '18 at 16:47











  • Yes, phone numbers are there and work doing the quickstart example.

    – Norman Morell Asensio
    Nov 27 '18 at 16:49






  • 1





    Seems silly but maybe Twilio really wants your XML responses to contain the XML preamble <?xml version="1.0" encoding="UTF-8"?>

    – Cody Caughlan
    Nov 27 '18 at 17:41











  • It doesn't work. Thanks @Cody Caughlan.

    – Norman Morell Asensio
    Nov 28 '18 at 8:48











  • 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.

    – Norman Morell Asensio
    Nov 28 '18 at 10:22

















I assume all NUMBER values are just placeholders and you have valid phone numbers there?

– Cody Caughlan
Nov 27 '18 at 16:47





I assume all NUMBER values are just placeholders and you have valid phone numbers there?

– Cody Caughlan
Nov 27 '18 at 16:47













Yes, phone numbers are there and work doing the quickstart example.

– Norman Morell Asensio
Nov 27 '18 at 16:49





Yes, phone numbers are there and work doing the quickstart example.

– Norman Morell Asensio
Nov 27 '18 at 16:49




1




1





Seems silly but maybe Twilio really wants your XML responses to contain the XML preamble <?xml version="1.0" encoding="UTF-8"?>

– Cody Caughlan
Nov 27 '18 at 17:41





Seems silly but maybe Twilio really wants your XML responses to contain the XML preamble <?xml version="1.0" encoding="UTF-8"?>

– Cody Caughlan
Nov 27 '18 at 17:41













It doesn't work. Thanks @Cody Caughlan.

– Norman Morell Asensio
Nov 28 '18 at 8:48





It doesn't work. Thanks @Cody Caughlan.

– Norman Morell Asensio
Nov 28 '18 at 8:48













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.

– Norman Morell Asensio
Nov 28 '18 at 10:22





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.

– Norman Morell Asensio
Nov 28 '18 at 10:22












1 Answer
1






active

oldest

votes


















0














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!






share|improve this answer



















  • 1





    You shouldn't need to hack the CurlClient.php core. You can do this in your calling code when instantiating your Twilio REST Client. You first create your own CurlClient and pass in an array of those curl options to its initializer; then pass that pre-configured httpclient into the constructor of your rest client and you should be good to go. Unfortunately this comment doesnt allow an adequate code example.

    – Cody Caughlan
    Nov 28 '18 at 17:17











  • Hi Cody! I tryed what you said: $options = array(CURLOPT_SSL_VERIFYPEER => false); $curlClient = new CurlClient($options); $client = new Client($account_sid, $auth_token,null,$curlClient); But not works. So I have to leave CurlClient.php hacked.

    – Norman Morell Asensio
    Nov 29 '18 at 16:09











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53504166%2ftwilio-call-and-play-mp3%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














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!






share|improve this answer



















  • 1





    You shouldn't need to hack the CurlClient.php core. You can do this in your calling code when instantiating your Twilio REST Client. You first create your own CurlClient and pass in an array of those curl options to its initializer; then pass that pre-configured httpclient into the constructor of your rest client and you should be good to go. Unfortunately this comment doesnt allow an adequate code example.

    – Cody Caughlan
    Nov 28 '18 at 17:17











  • Hi Cody! I tryed what you said: $options = array(CURLOPT_SSL_VERIFYPEER => false); $curlClient = new CurlClient($options); $client = new Client($account_sid, $auth_token,null,$curlClient); But not works. So I have to leave CurlClient.php hacked.

    – Norman Morell Asensio
    Nov 29 '18 at 16:09
















0














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!






share|improve this answer



















  • 1





    You shouldn't need to hack the CurlClient.php core. You can do this in your calling code when instantiating your Twilio REST Client. You first create your own CurlClient and pass in an array of those curl options to its initializer; then pass that pre-configured httpclient into the constructor of your rest client and you should be good to go. Unfortunately this comment doesnt allow an adequate code example.

    – Cody Caughlan
    Nov 28 '18 at 17:17











  • Hi Cody! I tryed what you said: $options = array(CURLOPT_SSL_VERIFYPEER => false); $curlClient = new CurlClient($options); $client = new Client($account_sid, $auth_token,null,$curlClient); But not works. So I have to leave CurlClient.php hacked.

    – Norman Morell Asensio
    Nov 29 '18 at 16:09














0












0








0







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!






share|improve this answer













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!







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 28 '18 at 10:38









Norman Morell AsensioNorman Morell Asensio

236




236








  • 1





    You shouldn't need to hack the CurlClient.php core. You can do this in your calling code when instantiating your Twilio REST Client. You first create your own CurlClient and pass in an array of those curl options to its initializer; then pass that pre-configured httpclient into the constructor of your rest client and you should be good to go. Unfortunately this comment doesnt allow an adequate code example.

    – Cody Caughlan
    Nov 28 '18 at 17:17











  • Hi Cody! I tryed what you said: $options = array(CURLOPT_SSL_VERIFYPEER => false); $curlClient = new CurlClient($options); $client = new Client($account_sid, $auth_token,null,$curlClient); But not works. So I have to leave CurlClient.php hacked.

    – Norman Morell Asensio
    Nov 29 '18 at 16:09














  • 1





    You shouldn't need to hack the CurlClient.php core. You can do this in your calling code when instantiating your Twilio REST Client. You first create your own CurlClient and pass in an array of those curl options to its initializer; then pass that pre-configured httpclient into the constructor of your rest client and you should be good to go. Unfortunately this comment doesnt allow an adequate code example.

    – Cody Caughlan
    Nov 28 '18 at 17:17











  • Hi Cody! I tryed what you said: $options = array(CURLOPT_SSL_VERIFYPEER => false); $curlClient = new CurlClient($options); $client = new Client($account_sid, $auth_token,null,$curlClient); But not works. So I have to leave CurlClient.php hacked.

    – Norman Morell Asensio
    Nov 29 '18 at 16:09








1




1





You shouldn't need to hack the CurlClient.php core. You can do this in your calling code when instantiating your Twilio REST Client. You first create your own CurlClient and pass in an array of those curl options to its initializer; then pass that pre-configured httpclient into the constructor of your rest client and you should be good to go. Unfortunately this comment doesnt allow an adequate code example.

– Cody Caughlan
Nov 28 '18 at 17:17





You shouldn't need to hack the CurlClient.php core. You can do this in your calling code when instantiating your Twilio REST Client. You first create your own CurlClient and pass in an array of those curl options to its initializer; then pass that pre-configured httpclient into the constructor of your rest client and you should be good to go. Unfortunately this comment doesnt allow an adequate code example.

– Cody Caughlan
Nov 28 '18 at 17:17













Hi Cody! I tryed what you said: $options = array(CURLOPT_SSL_VERIFYPEER => false); $curlClient = new CurlClient($options); $client = new Client($account_sid, $auth_token,null,$curlClient); But not works. So I have to leave CurlClient.php hacked.

– Norman Morell Asensio
Nov 29 '18 at 16:09





Hi Cody! I tryed what you said: $options = array(CURLOPT_SSL_VERIFYPEER => false); $curlClient = new CurlClient($options); $client = new Client($account_sid, $auth_token,null,$curlClient); But not works. So I have to leave CurlClient.php hacked.

– Norman Morell Asensio
Nov 29 '18 at 16:09




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53504166%2ftwilio-call-and-play-mp3%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)