1. Go to this page and download the library: Download romandenu/ringcentral-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
romandenu / ringcentral-php example snippets
$rcsdk = new RingCentral\SDK\SDK('clientId', 'clientSecret', RingCentral\SDK\SDK::SERVER_SANDBOX);
$rcsdk = new RingCentral\SDK\SDK('clientId', 'clientSecret', RingCentral\SDK\SDK::SERVER_SANDBOX, 'MyApp', '1.0.0');
// when application is going to be stopped
file_put_contents($file, json_encode($rcsdk->platform()->auth()->data(), JSON_PRETTY_PRINT));
// and then next time during application bootstrap before any authentication checks:
$rcsdk->platform()->auth()->setData(json_decode(file_get_contents($file), true));
$apiResponse = $rcsdk->platform()->get('/account/~/extension/~');
$apiResponse = $rcsdk->platform()->post('/account/~/extension/~', array(...));
$apiResponse = $rcsdk->platform()->put('/account/~/extension/~', array(...));
$apiResponse = $rcsdk->platform()->delete('/account/~/extension/~');
print_r($apiResponse->json()); // stdClass will be returned or exception if Content-Type is not JSON
print_r($apiResponse->request()); // PSR-7's RequestInterface compatible instance used to perform HTTP request
print_r($apiResponse->response()); // PSR-7's ResponseInterface compatible instance used as HTTP response
try {
$rcsdk->platform()->get('/account/~/whatever');
} catch (\RingCentral\SDK\Http\ApiException $e) {
// Getting error messages using PHP native interface
print 'Expected HTTP Error: ' . $e->getMessage() . PHP_EOL;
// In order to get Request and Response used to perform transaction:
$apiResponse = $e->apiResponse();
print_r($apiResponse->request());
print_r($apiResponse->response());
// Another way to get message, but keep in mind, that there could be no response if request has failed completely
print ' Message: ' . $e->apiResponse->response()->error() . PHP_EOL;
}
use GuzzleHttp\Client as GuzzleClient;
$guzzle = new GuzzleClient([
'proxy' => 'localhost:8888',
'verify' => false
]);
$rcsdk = new SDK("clientId", "clientSecret", SDK::SERVER_PRODUCTION, 'Demo', '1.0.0', $guzzle);
return array(
'username' => '18881112233', // your RingCentral account phone number
'extension' => null, // or number
'password' => 'yourPassword',
'clientId' => 'yourClientId',
'clientSecret' => 'yourClientSecret',
'server' => 'https://platform.devtest.ringcentral.com', // for production - https://platform.ringcentral.com
'smsNumber' => '18882223344', // any of SMS-enabled numbers on your RingCentral account
'mobileNumber' => '16501112233', // your own mobile number to which script will send sms
'dateFrom' => 'yyyy-mm-dd',
'dateTo' => 'yyyy-mm-dd'
);
sh
$ curl -sS https://getcomposer.org/installer | php
sh
$ php composer.phar
sh
$ php index.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.