Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Uncaught exception 'Services_Twilio_TinyHttpException' with message 'Couldn't resolve host 'api.twilio.com'' #229

Closed
vkandrikar opened this issue May 26, 2015 · 16 comments

Comments

@vkandrikar
Copy link

while making a voice call request getting below error

Fatal error: Uncaught exception 'Services_Twilio_TinyHttpException' with message 'Couldn't resolve host 'api.twilio.com'' in /home/www/BCARD/custom/CEMV/TEMP_CC/Services/Twilio/TinyHttp.php:119
Stack trace:
#0 /home/www/BCARD/custom/CEMV/TEMP_CC/Services/Twilio.php(179): Services_Twilio_TinyHttp->__call('post', Array)
#1 /home/www/BCARD/custom/CEMV/TEMP_CC/Services/Twilio.php(179): Services_Twilio_TinyHttp->post('/2010-04-01/Acc...', Array, 'Method=GET&Fall...')
#2 /home/www/BCARD/custom/CEMV/TEMP_CC/Services/Twilio/ListResource.php(92): Base_Services_Twilio->createData('/2010-04-01/Acc...', Array)
#3 /home/www/BCARD/custom/CEMV/TEMP_CC/Services/Twilio/Rest/Calls.php(32): Services_Twilio_ListResource->_create(Array)
#4 /home/www/BCARD/custom/CEMV/TEMP_CC/autoAlerting.php(100): Services_Twilio_Rest_Calls->create('+441290211984', '+918390786524', 'http://twimlets...', Array)
#5 /home/www/BCARD/custom/CEMV/TEMP_CC/autoAlerting.php(39): fnMakeVoiceCall('+918390786524', 'Hi, this is tes...')
#6 {main}

thrown in /home/www/BCARD/custom/CEMV/TEMP_CC/Services/Twilio/TinyHttp.php on line 119

@ezekel
Copy link

ezekel commented May 28, 2015

I am having problem too.

@vkandrikar
Copy link
Author

add below code at all files where u r getting error

$_h = curl_init();
curl_setopt($_h, CURLOPT_HEADER, 1);
curl_setopt($_h, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($_h, CURLOPT_HTTPGET, 1);
curl_setopt($_h, CURLOPT_URL, 'https://api.twilio.com' );
curl_setopt($_h, CURLOPT_PROXY, "YOUR IP");
curl_setopt($_h, CURLOPT_DNS_USE_GLOBAL_CACHE, false );
curl_setopt($_h, CURLOPT_DNS_CACHE_TIMEOUT, 2 );

curl_exec($_h);

@kevinburke
Copy link
Contributor

2 second DNS cache timeout is pretty aggressive. Can probably turn this
down to 60 (the default)

Kevin Burke
phone: 925.271.7005 | twentymilliseconds.com

On Sun, Jun 7, 2015 at 9:57 PM, Vijay Kandrikar notifications@github.com
wrote:

add below code at all files where u r getting error

$_h = curl_init();
curl_setopt($_h, CURLOPT_HEADER, 1);
curl_setopt($_h, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($_h, CURLOPT_HTTPGET, 1);
curl_setopt($_h, CURLOPT_URL, 'https://api.twilio.com' );
curl_setopt($_h, CURLOPT_PROXY, '35.56.104.42:8080');
curl_setopt($_h, CURLOPT_DNS_USE_GLOBAL_CACHE, false );
curl_setopt($_h, CURLOPT_DNS_CACHE_TIMEOUT, 2 );
curl_setopt($_h, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($_h, CURLOPT_SSL_VERIFYHOST, 2);

curl_exec($_h);


Reply to this email directly or view it on GitHub
#229 (comment).

@skimbrel
Copy link
Contributor

skimbrel commented Jun 8, 2015

Please do not encourage people to disable SSL peer verification! This leaves your application open to man-in-the-middle attacks against your traffic to Twilio, which means an attacker could read your messages or steal your Twilio API credentials. If your application throws errors related to SSL certificate validation, please see the FAQ: https://twilio-php.readthedocs.org/en/latest/faq.html#ssl-validation-exceptions

@ezekel
Copy link

ezekel commented Jun 16, 2015

@vkandrikar Is this will also will work in sending message ?

@dhavalstays
Copy link

@vkandrikar Where should I add that code. At line 128 it throws exception.

Fatal error: Uncaught exception 'Services_Twilio_TinyHttpException' with message 'Couldn't resolve host 'api.twilio.com'' in /Applications/AMPPS/www/Test/twilio/Services/Twilio/TinyHttp.php:128 Stack trace: #0 /Applications/AMPPS/www/Test/twilio/Services/Twilio.php(193): Services_Twilio_TinyHttp->__call('post', Array) #1 /Applications/AMPPS/www/Test/twilio/Services/Twilio.php(193): Services_Twilio_TinyHttp->post('/2010-04-01/Acc...', Array, 'From=%2B1650229...') #2 /Applications/AMPPS/www/Test/twilio/Services/Twilio/ListResource.php(92): Base_Services_Twilio->createData('/2010-04-01/Acc...', Array) #3 /Applications/AMPPS/www/Test/twilio/Services/Twilio/Rest/Messages.php(24): Services_Twilio_ListResource->_create(Array) #4 /Applications/AMPPS/www/Test/twilio/Services/Twilio/Rest/Messages.php(71): Services_Twilio_Rest_Messages->create(Array) #5 /Applications/AMPPS/www/Test/index.php(70): Services_Twilio_Rest_Messages->sendMessage('+XXXX', '+XXX', 'This is a test.') #6 {main} thrown in /Applications/AMPPS/www/Test/twilio/Services/Twilio/TinyHttp.php on line 128

@dhavalstays
Copy link

@ezekel Have you got the solution for this?

@ezekel
Copy link

ezekel commented Jun 17, 2015

@dhavalstays , I don't have yet. I am still struggling on this twillio

@dhavalstays
Copy link

@ezekel Please post the solution once you resolve it.

@vkandrikar
Copy link
Author

@ezekel
yes, it work for sending messages also

@vkandrikar
Copy link
Author

@dhavalstays
u can add the CURL code at very 1st line of php page before doing anything

    require('Services/Twilio.php'); 
$_h = curl_init();
curl_setopt($_h, CURLOPT_HEADER, 1);
curl_setopt($_h, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($_h, CURLOPT_HTTPGET, 1);
curl_setopt($_h, CURLOPT_URL, 'https://api.twilio.com' );
curl_exec($_h);

@ezekel
Copy link

ezekel commented Jun 25, 2015

@dhavalstays ,

do we need to purchase twilio phone number in order to send messages ?
because @devinrader said that,phone number should be purchase in twilio even you are in trial account.

see https://github.com/twilio/twilio-php/issues/230#issuecomment-114804049

@andriytkachiv
Copy link

This is still not resolved. I don't understand, its a commercial library, is it maintain??

@ihumanable ihumanable added the 4.x label Aug 16, 2016
@codejudas
Copy link
Contributor

We've completely rewritten the library for 5.x, please upgrade and let us know if this is still an issue.

@Omazon
Copy link

Omazon commented Aug 22, 2018

I have the same issue, I haven't been able to resolve, I use the composer package (for laravel), I use the 5.21v, any idea, someone please!!
NOTE: in localhost its working, but in production, I have that error

@imthepitts
Copy link
Contributor

@Omazon if this issue started since Aug. 20, it may be due to our updated root certificate:

https://support.twilio.com/hc/en-us/articles/360007853433-Troubleshooting-Certificate-Errors-for-the-REST-API

If you need additional assistance, please contact our Support team: https://www.twilio.com/help/contact

All the Best,
Zack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants