0

我创建了一个Server-only (No UI)具有读取呼叫日志权限的私有应用程序,当登录时出现以下错误:

Exception: Invalid response string SDK HTTP Error at https:///platform.devtest.ringcentral.com/restapi/oauth/token Response text: Previous: Invalid response string #0 /srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/ringcentral-php/src/Platform/Platform.php(214): RingCentral\SDK\Http\Client->send(Object(RingCentral\Psr7\Request)) \#1 /srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/ringcentral-php/src/Platform/Platform.php(301): RingCentral\SDK\Platform\Platform->sendRequest(Object(RingCentral\Psr7\Request), Array) #2 /srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/ringcentral-php/src/Platform/Platform.php(123): RingCentral\SDK\Platform\Platform->requestToken('/restapi/oauth/...', Array) #3 /srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/demo/callRecording.php(25): RingCentral\SDK\Platform\Platform->login('+15188315198', 101, 'xxxxxxxxxxxx', true) #4 {main}

我错过了什么?为什么我会收到此错误?这是代码:

require_once('_bootstrap.php');

use RingCentral\SDK\SDK;

// Create SDK instance

$credentials = array(
    'username'     => '+15188315198',       // your RingCentral account phone number
    'extension'    => 101,              // or number
    'password'     => 'xxxxxxxxxxxx',
    'appKey'       => 'xxxxxxxxxxxxxxx',
    'appSecret'    => 'xxxxxxxxxxx',
    'server'       => 'https:platform.devtest.ringcentral.com',
    'dateFrom' => '1/1/2016'
); 

$rcsdk = new SDK($credentials['appKey'], $credentials['appSecret'], $credentials['server'], 'Demo', '1.0.0');

$platform = $rcsdk->platform();

$platform->login($credentials['username'], $credentials['extension'], $credentials['password'], true);
4

4 回答 4

0
  1. 是的,我使用 Composer 安装了 RingCentral PHP SDK
  2. 我替换了 require_once('_bootstrap.php'); 使用 require_once("vendor/autoload.php"); 虽然这是演示使用的,但我仍然得到错误。
  3. 我尝试了您包含的简单登录示例,但我得到了同样的错误

致命错误:在 /srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/psr7/src/functions.php:478 中未捕获的异常“InvalidArgumentException”和消息“无效的响应字符串”堆栈跟踪:#0 /srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/ringcentral-php/src/Http/ApiResponse.php(56): RingCentral\Psr7\parse_response ('HTTP/1.1 0 OK\r\n') #1 /srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/ringcentral-php/src/Http/Client. php(99): RingCentral\SDK\Http\ApiResponse->__construct(Object(RingCentral\Psr7\Request), false, 0) #2 /srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php- master/vendor/ringcentral/ringcentral-php/src/Http/Client.php(25): RingCentral\SDK\Http\Client->loadResponse(对象(RingCentral\Psr7\Request))#3 /srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/ringcentral-php/src/Platform/Platform.php( 214):RingCentral\SDK\Http\Client->在/srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/ringcentral-php/src/Http/Client.php上第 44 行

于 2016-07-29T15:12:39.147 回答
0

您能否验证CURLOPT_SSL_VERIFYPEER设置是否正确。

您可以参考此问题以获取更多信息: 设置 CURLOPT_SSL_VERIFYPEER

于 2016-08-08T00:59:53.133 回答
0

您能否确认一下,您是否使用 Composer 安装了我们的 PHP SDK?

如果有,您能否确认是否遵循了以下提到的步骤:

1.) 使用 Composer 安装 RingCentral PHP SDK

https://github.com/ringcentral/ringcentral-php#with-composer-recommended 

2.) 您需要在 PHP 脚本中使用 Composer 的 AutoLoader。

require_once(__DIR__ . '/vendor/autoload.php'); 

假设文件夹结构如下所示:

您的应用程序(应用程序名称)
-vendor(使用 Composer 安装的 PHP SDK)
-index.php(应用程序的 PHP 脚本)

请在应用程序的 index.php 脚本中包含“AutoLoader”。

下面是示例代码的样子:

<?php 

require_once(__DIR__ . '/vendor/autoload.php'); 

use RingCentral\SDK\SDK; 

// Create SDK instance 
$rcsdk = new SDK("appKey", "appSecret" , "https://platform.devetst.ringcentral.com", 'Demo', '1.0.0'); 

// Create Platform Singleton Instance 
$platform = $rcsdk->platform(); 

// Login 
$auth = $platform->login("Username", "extension", "password"); 

// Respsone 
print 'Login Success' . $auth->text() . PHP_EOL; 
于 2016-07-27T21:27:59.930 回答
0

我添加了 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 在 client.php 的第 73 行,它没有任何区别。

致命错误:/srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/psr7/src/functions.php:478 中未捕获的异常“InvalidArgumentException”和消息“无效的响应字符串”堆栈跟踪:#0 /srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/ringcentral-php/src/Http/ApiResponse.php(56): RingCentral\Psr7\parse_response ('HTTP/1.1 0 OK\r\n') #1 /srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/ringcentral-php/src/Http/Client. php(99): RingCentral\SDK\Http\ApiResponse->__construct(Object(RingCentral\Psr7\Request), false, 0) #2 /srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php- master/vendor/ringcentral/ringcentral-php/src/Http/Client.php(25): RingCentral\SDK\Http\Client->loadResponse(对象(RingCentral\Psr7\Request))#3 /srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/ringcentral-php/src/Platform/Platform.php( 214):RingCentral\SDK\Http\Client-> 在 /srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/ringcentral-php/src/Http/Client.php 上第 44 行

于 2016-08-12T16:50:31.407 回答