2016-07-20 27 views
0

我創建了一個Server-only (No UI)專用的應用程序,以讀取通話記錄的權限,並且在登錄時發出我收到以下錯誤:RingCentral API登錄返回無效響應字符串

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); 

回答

0

,請證實,如果你已經安裝了我們的使用PHP作曲家SDK?

如果你有,你能不能確認是否遵循以下提到的步驟:

1)使用作曲安裝RingCentral PHP SDK

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

2)您將需要需要作曲家的自動裝載在你的PHP腳本中。

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

比方說文件夾結構是這樣的,如下:

your application (application name)
-vendor (PHP SDK whihc is installed using Composer)
-index.php (application's PHP Script)

請提供您的應用程序內的index.php文件腳本中的「自動裝載」。

下面是示例代碼會是什麼樣子:

<?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; 
0
  1. 是的,我用作曲
  2. 我更換放在require_once安裝RingCentral PHP SDK( '_ bootstrap.php中');與require_once(「vendor/autoload.php」);雖然這是演示使用 ,我仍然得到錯誤。
  3. 我想你包括簡單的登錄例子,我也得到了同樣的錯誤

致命錯誤:未捕獲的異常「InvalidArgumentException」在/srv/www/vhosts/internal.kingscredit消息「無效響應字符串」。 com/includes/ringcentral-php-master/vendor/ringcentral/psr7/src/functions.php:478堆棧跟蹤:#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/vhost src/Http/Client.php(25):RingCentral \ SDK \ Http \ Client-> loadResponse(Object(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->在44行/srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/ringcentral-php/src/Http/Client.php

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中發生無法識別異常'InvalidArgumentException',並顯示消息'Invalid response string' .php:478 Stack trace:#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 \ SDK \ Http \ Client-> loadResponse(Object(RingCentral \ Psr7 \ Request))#3/srv/WWW/v hosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/ringcentral-php/src/Platform/Platform.php(214):RingCentral \ SDK \ Http \ Client-> in/srv/www/vhosts/internal.kingscredit.com/includes/ringcentral-php-master/vendor/ringcentral/ringcentral-php/src/Http/Client.php 44行