Twilio应用程序在Google App Engine上托管,但在PHP SDK中不在本地

时间:2015-01-04 06:37:31

标签: php google-app-engine twilio

尝试创建新的子帐户时,此代码在部署时(在https://和http:// appspot网址上)有效,但在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();

}

当我在本地运行时,我收到此错误:

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

SDK是最新的,我昨天直接从Twilio下载了PHP库。

对于为什么会发生这种情况的任何意见都将不胜感激!

2 个答案:

答案 0 :(得分:2)

以下是我解决问题的方法。在Twilio.php上方修改verify_peer,添加以下行:

'cafile'        => '/etc/ssl/certs/ca-certificates.crt',

这个修复程序适用于运行PHP 5.5.9的Ubuntu 14.04。

答案 1 :(得分:1)

我无法进行投票或评论,但Ron DeFulio的解决方案也适用于我。

希望来自Twilio的人看到这个并且插话。

我已经将这个帖子的链接添加到Twilio关于同一问题的开放支持票证中。