Twilio应用程序在Google App Engine上托管时运行,但不能在PHP SDK本地运行


Twilio app works while hosted on Google App Engine but not locally in the PHP SDK

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

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

这是我解决问题的方法。编辑Twilio.phpverify_peer 正上方,添加以下行:

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

此修复程序在运行 PHP 14.04 的 Ubuntu 5.5.9 上对我有用。

我不能投票或评论,但 Ron DeFulio 的修复也对我有用。

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

我已经在与

Twilio 就同一问题提供的开放支持票证中添加了指向此线程的链接。

相关文章: