Пример #1
0
 protected function getSDK($authorized = true)
 {
     date_default_timezone_set('UTC');
     $sdk = new SDK('whatever', 'whatever', 'https://whatever', 'SDKTests', SDK::VERSION, $authorized, $authorized);
     if ($authorized) {
         $sdk->mockRegistry()->authenticationMock();
         $sdk->platform()->login('18881112233', null, 'password');
     }
     return $sdk;
 }
Пример #2
0
<?php

require_once __DIR__ . '/_bootstrap.php';
use RingCentral\SDK\SDK;
// Create SDK instance
$credentials = (require __DIR__ . '/_credentials.php');
$rcsdk = new SDK($credentials['appKey'], $credentials['appSecret'], $credentials['server'], 'Demo', '1.0.0');
$platform = $rcsdk->platform();
// Authorize
$platform->login($credentials['username'], $credentials['extension'], $credentials['password'], true);
// Find call log records with recordings
$callLogRecords = $platform->get('/account/~/extension/~/call-log', array('type' => 'Voice', 'withRecording' => 'True', 'dateFrom' => $credentials['dateFrom'], 'dateTo' => $credentials['dateTo']))->json()->records;
// Create a CSV file to log the records
$status = "Success";
$dir = $credentials['dateFrom'];
$fname = "recordings_{$dir}.csv";
$fdir = "/Recordings/{$dir}";
if (is_dir($fdir) === false) {
    mkdir($fdir, 0777, true);
}
$file = fopen($fname, 'w');
$fileHeaders = array("RecordingID", "ContentURI", "Filename", "DownloadStatus");
fputcsv($file, $fileHeaders);
$fileContents = array();
$timePerRecording = 6;
foreach ($callLogRecords as $i => $callLogRecord) {
    $id = $callLogRecord->recording->id;
    $uri = $callLogRecord->recording->contentUri;
    $apiResponse = $platform->get($callLogRecord->recording->contentUri);
    $ext = $apiResponse->response()->getHeader('Content-Type')[0] == 'audio/mpeg' ? 'mp3' : 'wav';
    $start = microtime(true);
Пример #3
0
 private function connectToLiveServer($server)
 {
     $sdk = new SDK('foo', 'bar', $server);
     $res = $sdk->platform()->get('', array(), array(), array('skipAuthCheck' => true))->json();
     $this->assertEquals('v1.0', $res->uriString);
 }
Пример #4
0
<?php

require_once __DIR__ . '/_bootstrap.php';
use RingCentral\SDK\SDK;
// Create SDK instance
$credentials = (require __DIR__ . '/_credentials.php');
$rcsdk1 = new SDK($credentials['appKey'], $credentials['appSecret'], $credentials['server'], 'Demo', '1.0.0');
$rcsdk2 = new SDK($credentials['appKey'], $credentials['appSecret'], $credentials['server'], 'Demo', '1.0.0');
$platform1 = $rcsdk1->platform();
$platform2 = $rcsdk2->platform();
$platform1->login($credentials['username'], $credentials['extension'], $credentials['password']);
print 'Platform1 Authorized' . PHP_EOL;
// Share P1 auth data with P2
$platform2->auth()->setData($platform1->auth()->data());
// Make first refresh
$platform1->refresh();
try {
    // Attempt to make second refresh
    $platform2->refresh();
    print 'Tokens should be identical' . PHP_EOL;
    print $platform1->auth()->accessToken() . PHP_EOL;
    print $platform2->auth()->accessToken() . PHP_EOL;
} catch (\Exception $e) {
    print 'Failed to do double refresh: ' . $e->getMessage() . PHP_EOL;
    print $e->getTraceAsString() . PHP_EOL;
    $extension = $platform1->get('/account/~/extension/~')->json();
    print 'Platform1 is still alive though: ' . $extension->name . PHP_EOL;
}