Reputation: 876
When trying to create a new sub account, this code works when deployed (on both https:// and http:// appspot URLs) but not locally in the SDK:
require 'php/twilio-php/Services/Twilio.php';
require 'php/includes/twil_creds.php';
$client = new Services_Twilio($account_sid, $auth_token);
try {
$account = $client->accounts->create(array(
'FriendlyName' => 'New Account'
));
} catch(Services_Twilio_RestException $e) {
echo $e->getMessage();
}
When I run it locally I get this error:
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in C:\ivr3mil\php\twilio-php\Services\Twilio\HttpStream.php on line 62
Warning: file_get_contents(): Failed to enable crypto in C:\ivr3mil\php\twilio-php\Services\Twilio\HttpStream.php on line 62
Warning: file_get_contents(https://api.twilio.com/2010-04-01/Accounts.json): failed to open stream: operation failed in C:\ivr3mil\php\twilio-php\Services\Twilio\HttpStream.php on line 62
Fatal error: Uncaught exception 'Services_Twilio_HttpStreamException' with message 'Unable to connect to service' in C:\ivr3mil\php\twilio-php\Services\Twilio\HttpStream.php:65 Stack trace: #0 C:\ivr3mil\php\twilio-php\Services\Twilio.php(226): Services_Twilio_HttpStream->__call('post', Array) #1 C:\ivr3mil\php\twilio-php\Services\Twilio.php(226): Services_Twilio_HttpStream->post('/2010-04-01/Acc...', Array, 'FriendlyName=Ne...') #2 C:\ivr3mil\php\twilio-php\Services\Twilio\ListResource.php(92): Services_Twilio->createData('/2010-04-01/Acc...', Array) #3 C:\ivr3mil\php\twilio-php\Services\Twilio\Rest\Accounts.php(23): Services_Twilio_ListResource->_create(Array) #4 C:\ivr3mil\twiltest.php(11): Services_Twilio_Rest_Accounts->create(Array) #5 C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\php\setup.php(106): require('C:\\ivr3mil\\twil...') #6 {main} thrown in C:\ivr3mil\php\twilio-php\Services\Twilio\HttpStream.php on line 65
The SDK is up to date and I downloaded the PHP Library from Twilio directly yesterday.
Any input as to why this is happening would be appreciated!
Upvotes: 1
Views: 406
Reputation: 252
I can't upvote or comment but Ron DeFulio's fix worked for me as well.
Hoping someone from Twilio sees this one and chimes in.
I've added a link to this thread to my open support ticket with Twilio regarding this same issue.
Upvotes: 1
Reputation: 135
Here's how I fixed the problem. Edit Twilio.php
, right above verify_peer
, add this line:
'cafile' => '/etc/ssl/certs/ca-certificates.crt',
This fix worked for me on Ubuntu 14.04 running PHP 5.5.9.
Upvotes: 2