} $json = array('type' => 'project', 'minimum-stability' => 'dev', 'require' => array('ringcentral/ringcentral-php' => 'dev-master')); if (!empty($argv) && in_array('develop', $argv)) { $json['require']['ringcentral/ringcentral-php'] = 'dev-develop'; } if (!empty($argv) && in_array('local', $argv)) { $json['repositories'] = array(array('url' => __DIR__, 'type' => 'vcs')); } print 'Composer config:' . PHP_EOL; print_r($json); print PHP_EOL . PHP_EOL; file_put_contents('./dist/phar/composer.json', json_encode($json)); exec('cd ' . __DIR__ . '/dist/phar && composer install --prefer-source --no-interaction --no-dev'); listDir(__DIR__ . '/dist/phar/vendor', '', $phar); $phar->setStub($phar->createDefaultStub("autoload.php")); ///// require './dist/ringcentral.phar'; try { if (!file_exists('demo/_credentials.php')) { print 'Connection check skipped.'; exit; } $credentials = (require 'demo/_credentials.php'); $sdk = new RingCentral\SDK\SDK($credentials['appKey'], $credentials['appSecret'], $credentials['server']); $sdk->getPlatform()->authorize($credentials['username'], $credentials['extension'], $credentials['password'], true); $t = $sdk->getPlatform()->get('/restapi/v1.0'); print 'Connected to API server ' . $t->getJson()->uri . ', version ' . $t->getJson()->versionString . PHP_EOL; } catch (Exception $e) { print 'Error while connecting using PHAR: ' . $e->getMessage(); exit(1); }
} $json = array('type' => 'project', 'minimum-stability' => 'dev', 'require' => array('ringcentral/ringcentral-php' => 'dev-master')); if (!empty($argv) && in_array('develop', $argv)) { $json['require']['ringcentral/ringcentral-php'] = 'dev-develop'; } if (!empty($argv) && in_array('local', $argv)) { $json['repositories'] = array(array('url' => __DIR__, 'type' => 'vcs')); } print 'Composer config:' . PHP_EOL; print_r($json); print PHP_EOL . PHP_EOL; file_put_contents('./dist/phar/composer.json', json_encode($json)); exec('cd ' . __DIR__ . '/dist/phar && composer install --prefer-source --no-interaction --no-dev'); listDir(__DIR__ . '/dist/phar/vendor', '', $phar); $phar->setStub($phar->createDefaultStub("autoload.php")); ///// require './dist/ringcentral.phar'; try { if (!file_exists('demo/_credentials.php')) { print 'Connection check skipped.'; exit; } $credentials = (require 'demo/_credentials.php'); $sdk = new RingCentral\SDK\SDK($credentials['appKey'], $credentials['appSecret'], $credentials['server']); $sdk->platform()->login($credentials['username'], $credentials['extension'], $credentials['password']); $t = $sdk->platform()->get('/restapi/v1.0'); print 'Connected to API server ' . $t->json()->uri . ', version ' . $t->json()->versionString . PHP_EOL; } catch (Exception $e) { print 'Error while connecting using PHAR: ' . $e->getMessage(); exit(1); }