Я пытаюсь отправить смс через RingCentral. Это ошибка, которую я получаю ниже.
Неустранимая ошибка: неперехваченное исключение: ответ имеет неудачный статус в /Applications/MAMP/htdocs/Paradise/wp-content/plugins/ring-central/vendor/ringcentral/ringcentral-php/src/Http/Client.php:39 трассировки стека: # 0 /Applications/MAMP/htdocs/Paradise/wp-content/plugins/ring-central/vendor/ringcentral/ringcentral-php/src/Platform/Platform.php(276): RingCentral \ SDK \ Http \ Client-> send (Объект (GuzzleHttp \ Psr7 \ Request)) # 1 /Applications/MAMP/htdocs/Paradise/wp-content/plugins/ring-central/vendor/ringcentral/ringcentral-php/src/Platform/Platform.php(363): RingCentral \ SDK \ Platform \ Platform-> sendRequest (Объект (GuzzleHttp \ Psr7 \ Request), Массив) # 2 / Приложения / MAMP / htdocs / Paradise / wp-content / плагины / ring-central / vendor / ringcentral / ringcentral-php /src/Platform/Platform.php(183): RingCentral \ SDK \ Platform \ Platform-> requestToken (‘/ restapi / oauth / …’, Array) # 3 / Приложения / MAMP / htdocs / Paradise / wp-content /plugins/ring-central/includes/ring-central.class.php(26): RingCentral \ SDK \ Platform \ Platform-> login (обр. ау, ‘# Gc090486’, ‘101’) # 4 / Applicati в /Applications/MAMP/htdocs/Paradise/wp-content/plugins/ring-central/vendor/ringcentral/ringcentral-php/src/Http/Client.php на линии 50
<?php
use RingCentral\SDK\SDK;
define("FAILED", 1);
define("LOCKED", 2);
class RingCentralConnection {
private $_sdk;
private $_platform;
function __construct($clientId, $secret) {
}
//https://platform.ringcentral.com/restapi/v1.0/account/159048008/extension/171857008/call-log?dateFrom=2012-08-26
public function sendSMS($from, $to, $text) {
$_credentials = require (getPluginDir().'/includes/credentials.php');
$_sdk = new SDK($_credentials['appKey'], $_credentials['appSecret'], $_credentials['server'], '2FA Demo', '1.0.0');
//print_r($_sdk);
$_platform = $_sdk->platform();
try {
$_platform->login($_credentials['username'], $_credentials['extension'], $_credentials['password']);
// $code = generateRandomCode(6);
// $myNumber = $_credentials['username'];
// try {
// $response = $_platform->post('/account/~/extension/~/sms', array(
// 'from' => array('phoneNumber' => $myNumber),
// 'to' => array(array('phoneNumber' => $to)),
// 'text' => $message
// ));
// $status = $response->json()->messageStatus;
// echo $status;
// if ($status == "SendingFailed" || $status == "DeliveryFailed") {
// //$db->close();
// createResponse(new Response(FAILED, "RC server connection error. Please try again."));
// } else {
// //$timeStamp = time();
// //$query = "UPDATE users SET code= " . $code . ", codeexpiry= " . $timeStamp . " WHERE email='" . $email . "'";
// //$db->query($query);
// //$db->close();
// createResponse(new Response(LOCKED, $message));
// }
// } catch (ApiException $e) {
// //$db->close();
// $this->createResponse(new Response(FAILED, "RC server connection error. Please try again in."));
// }
} catch (ApiException $e) {
//$db->close();
//print_r($e);
$this->createResponse(new Response(FAILED, "RC server connection error. Please try again out."));
}
}
function createResponse($res) {
$response = json_encode($res);
echo $response;
}
function databaseError() {
$res = new Response(UNKNOWN, "Unknown database error. Please try again.");
$response = json_encode($res);
die($response);
}
}
class Response {
function __construct($error, $message) {
$this->error = $error;
$this->message = $message;
}
public $error;
public $message;
}
//credentials
return array(
'username' => '+13128589951',
'extension' => '101', // extension number
'password' => '',
'appKey' => '',
'appSecret' => '',
'server' => 'https://platform.devtest.ringcentral.com'// for production - https://platform.ringcentral.com
);
Задача ещё не решена.
Других решений пока нет …