*/ include __DIR__ . '/../vendor/autoload.php'; use TopfaceLibrary\SmsOnline\Bulk\Client; use TopfaceLibrary\SmsOnline\Bulk\Message; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Option; use alxmsl\Cli\Exception\RequiredOptionException; $from = ''; $phones = []; $secret = ''; $text = ''; $user = ''; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('from', 'f', 'sender alpha-name', Option::TYPE_STRING, true), function ($name, $value) use(&$from) { $from = (string) $value; }); $Command->appendParameter(new Option('phone', 'p', 'receiver phone or phones (comma-separated)', Option::TYPE_STRING, true), function ($name, $value) use(&$phones) { $phones = explode(',', $value); }); $Command->appendParameter(new Option('secret', 's', 'secret key', Option::TYPE_STRING, true), function ($name, $value) use(&$secret) { $secret = (string) $value; }); $Command->appendParameter(new Option('text', 't', 'message text', Option::TYPE_STRING, true), function ($name, $value) use(&$text) { $text = (string) $value; }); $Command->appendParameter(new Option('user', 'u', 'sender login', Option::TYPE_STRING, true), function ($name, $value) use(&$user) { $user = (string) $value; }); try { $Command->parse(true);
* Script for Google API authorization * @author alxmsl */ include __DIR__ . '/../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; use alxmsl\Google\AndroidPublisher\Purchases\Subscriptions\SubscriptionsClient; $accessToken = ''; $packageName = ''; $subscriptionId = ''; $token = ''; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('access', 'a', 'access token', Option::TYPE_STRING, true), function ($name, $value) use(&$accessToken) { $accessToken = $value; }); $Command->appendParameter(new Option('package', 'p', 'package name', Option::TYPE_STRING, true), function ($name, $value) use(&$packageName) { $packageName = $value; }); $Command->appendParameter(new Option('subscription', 's', 'subscription id', Option::TYPE_STRING, true), function ($name, $value) use(&$subscriptionId) { $subscriptionId = $value; }); $Command->appendParameter(new Option('token', 't', 'purchase token', Option::TYPE_STRING, true), function ($name, $value) use(&$token) { $token = $value; }); try { $Command->parse(true); $Client = new SubscriptionsClient(); $Client->setPackage($packageName)->setAccessToken($accessToken); $Resource = $Client->get($subscriptionId, $token);
* Copyright 2015 Alexey Maslov <*****@*****.**> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Usage example with composer * Make composer install first * @author alxmsl * @date 5/24/14 */ include '../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Option; // Create command instance $Command = new CommandPosix(); // Append created option for help to command $Command->appendHelpParameter('show help screen option'); // Append one required option. And... $Command->appendParameter(new Option('option', 'o', 'some option', Option::TYPE_BOOLEAN)); $Command->appendParameter(new Option('value', 'v', 'some value', Option::TYPE_STRING, true)); // ...just parse the command $Command->parse();
include __DIR__ . '/../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; use alxmsl\Odnoklassniki\API\Client; use alxmsl\Odnoklassniki\OAuth2\Response\Token; $accessToken = ''; $applicationKey = ''; $clientId = ''; $clientSecret = ''; $methodName = ''; $methodData = ''; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('client', 'c', 'client id', Option::TYPE_STRING, true), function ($name, $value) use(&$clientId) { $clientId = $value; }); $Command->appendParameter(new Option('data', 'd', 'API method parameters (JSON)', Option::TYPE_STRING, true), function ($name, $value) use(&$methodData) { $methodData = json_decode($value, true); }); $Command->appendParameter(new Option('key', 'k', 'application key', Option::TYPE_STRING, true), function ($name, $value) use(&$applicationKey) { $applicationKey = $value; }); $Command->appendParameter(new Option('method', 'm', 'API method name', Option::TYPE_STRING, true), function ($name, $value) use(&$methodName) { $methodName = $value; }); $Command->appendParameter(new Option('secret', 's', 'client secret', Option::TYPE_STRING, true), function ($name, $value) use(&$clientSecret) { $clientSecret = $value; }); $Command->appendParameter(new Option('token', 't', 'access token', Option::TYPE_STRING, true), function ($name, $value) use(&$accessToken) { $accessToken = $value;
* Authenticate card script * @author alxmsl */ include __DIR__ . '/../../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; use alxmsl\PaymentNinja\Client; $publicKey = ''; $privateKey = ''; $payerResponse = ''; $merchantData = ''; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('data', 'd', 'ACS merchant data', Option::TYPE_STRING, true), function ($name, $value) use(&$merchantData) { $merchantData = (string) $value; }); $Command->appendParameter(new Option('private', 'r', 'project private key', Option::TYPE_STRING, true), function ($name, $value) use(&$privateKey) { $privateKey = (string) $value; }); $Command->appendParameter(new Option('public', 'b', 'project public key', Option::TYPE_STRING, true), function ($name, $value) use(&$publicKey) { $publicKey = (string) $value; }); $Command->appendParameter(new Option('response', 'e', 'ACS payer response', Option::TYPE_STRING, true), function ($name, $value) use(&$payerResponse) { $payerResponse = (string) $value; }); try { $Command->parse(true); $Client = new Client($publicKey, $privateKey); $Response = $Client->cardAuthenticate($payerResponse, $merchantData)->execute(); printf("%s\n", $Response);
* @author alxmsl */ include __DIR__ . '/../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; use alxmsl\Odnoklassniki\OAuth2\Client; use alxmsl\Odnoklassniki\OAuth2\Response\Token; $clientId = ''; $clientSecret = ''; $redirectUri = ''; $refreshToken = ''; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('client', 'c', 'client id', Option::TYPE_STRING, true), function ($name, $value) use(&$clientId) { $clientId = $value; }); $Command->appendParameter(new Option('redirect', 'r', 'redirect uri', Option::TYPE_STRING, true), function ($name, $value) use(&$redirectUri) { $redirectUri = $value; }); $Command->appendParameter(new Option('token', 't', 'refresh token', Option::TYPE_STRING, true), function ($name, $value) use(&$refreshToken) { $refreshToken = $value; }); $Command->appendParameter(new Option('secret', 's', 'client secret', Option::TYPE_STRING, true), function ($name, $value) use(&$clientSecret) { $clientSecret = $value; }); try { $Command->parse(true); $Client = new Client(); $Client->setClientId($clientId)->setClientSecret($clientSecret)->setRedirectUri($redirectUri); $Token = $Client->refresh($refreshToken);
*/ include __DIR__ . '/../../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; use alxmsl\PaymentNinja\Client; $currency = null; $interval = null; $price = null; $privateKey = ''; $publicKey = ''; $user = ''; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('currency', 'c', 'recurring currency code (ISO 4217)', Option::TYPE_STRING), function ($name, $value) use(&$currency) { $currency = (string) $value; }); $Command->appendParameter(new Option('interval', 'i', 'automatic recurring interval in days (if set 0, then only manual recurring will remain active)', Option::TYPE_STRING), function ($name, $value) use(&$interval) { $interval = (int) $value; }); $Command->appendParameter(new Option('price', 'p', 'recurring payment price', Option::TYPE_STRING), function ($name, $value) use(&$price) { $price = (double) $value; }); $Command->appendParameter(new Option('private', 'r', 'project private key', Option::TYPE_STRING, true), function ($name, $value) use(&$privateKey) { $privateKey = (string) $value; }); $Command->appendParameter(new Option('public', 'b', 'project public key', Option::TYPE_STRING, true), function ($name, $value) use(&$publicKey) { $publicKey = (string) $value; }); $Command->appendParameter(new Option('user', 'u', 'user identifier', Option::TYPE_STRING, true), function ($name, $value) use(&$user) { $user = (string) $value;
* @author alxmsl */ include __DIR__ . '/../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; use alxmsl\Google\GCM\Client; use alxmsl\Google\GCM\Message\CustomPayloadData; use alxmsl\Google\GCM\Message\PayloadMessage; $data = ''; $id = ''; $key = ''; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('data', 'd', 'payload data', Option::TYPE_STRING), function ($name, $value) use(&$data) { $data = json_decode($value, true); }); $Command->appendParameter(new Option('id', 'i', 'device registration id', Option::TYPE_STRING, true), function ($name, $value) use(&$id) { $id = $value; }); $Command->appendParameter(new Option('key', 'k', 'authorization key', Option::TYPE_STRING, true), function ($name, $value) use(&$key) { $key = $value; }); try { $Command->parse(true); // Create payload instance $Data = new CustomPayloadData($data); // Create and initialize message instance $Message = new PayloadMessage(); $Message->setRegistrationIds($id)->setType(PayloadMessage::TYPE_JSON)->setData($Data); // Create GCM client
include __DIR__ . '/../../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; use alxmsl\PaymentNinja\Client; $currency = ''; $description = null; $orderId = null; $price = 0.0; $privateKey = ''; $publicKey = ''; $user = ''; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('currency', 'c', 'currency code (ISO 4217)', Option::TYPE_STRING, true), function ($name, $value) use(&$currency) { $currency = (string) $value; }); $Command->appendParameter(new Option('description', 'd', 'product description', Option::TYPE_STRING), function ($name, $value) use(&$description) { $description = (string) $value; }); $Command->appendParameter(new Option('order', 'o', 'merchant\'s order ID that will be returned back in a callback', Option::TYPE_STRING), function ($name, $value) use(&$orderId) { $orderId = (int) $value; }); $Command->appendParameter(new Option('price', 'p', 'price in real currency', Option::TYPE_STRING, true), function ($name, $value) use(&$price) { $price = (double) $value; }); $Command->appendParameter(new Option('private', 'r', 'project private key', Option::TYPE_STRING, true), function ($name, $value) use(&$privateKey) { $privateKey = (string) $value; }); $Command->appendParameter(new Option('public', 'b', 'project public key', Option::TYPE_STRING, true), function ($name, $value) use(&$publicKey) { $publicKey = (string) $value;
*/ include __DIR__ . '/../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; use alxmsl\Google\AndroidPublisher\Purchases\Subscriptions\SubscriptionsClient; $accessToken = ''; $expireTime = 0; $desireTime = 0; $packageName = ''; $subscriptionId = ''; $token = ''; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('access', 'a', 'access token', Option::TYPE_STRING, true), function ($name, $value) use(&$accessToken) { $accessToken = $value; }); $Command->appendParameter(new Option('expire', 'e', 'expire timestamp, milliseconds', Option::TYPE_STRING, true), function ($name, $value) use(&$expireTime) { $expireTime = (int) $value; }); $Command->appendParameter(new Option('desire', 'd', 'desire timestamp, milliseconds', Option::TYPE_STRING, true), function ($name, $value) use(&$desireTime) { $desireTime = (int) $value; }); $Command->appendParameter(new Option('package', 'p', 'package name', Option::TYPE_STRING), function ($name, $value) use(&$packageName) { $packageName = $value; }); $Command->appendParameter(new Option('subscription', 's', 'subscription id', Option::TYPE_STRING, true), function ($name, $value) use(&$subscriptionId) { $subscriptionId = $value; }); $Command->appendParameter(new Option('token', 't', 'purchase token', Option::TYPE_STRING, true), function ($name, $value) use(&$token) { $token = $value;
* * Utility for Telegram Bot API method call * @author alxmsl */ include __DIR__ . '/../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Option; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Telegram\Bot\Client; $key = ''; $methodName = ''; $parameters = []; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('method', 'm', 'bot method name', Option::TYPE_STRING, true), function ($name, $value) use(&$methodName) { $methodName = $value; }); $Command->appendParameter(new Option('parameters', 'p', 'method calls parameters', Option::TYPE_STRING), function ($name, $value) use(&$parameters) { $parameters = json_decode($value, true); }); $Command->appendParameter(new Option('token', 't', 'authentication token', Option::TYPE_STRING, true), function ($name, $value) use(&$key) { $key = $value; }); try { $Command->parse(true); $Client = new Client($key); $result = $Client->call($methodName, $parameters); printf("%s\n", $result); } catch (RequiredOptionException $Ex) { $Command->displayHelp(); }
* * Cancel user's recurring script * @author alxmsl */ include __DIR__ . '/../../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; use alxmsl\PaymentNinja\Client; $publicKey = ''; $privateKey = ''; $user = ''; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('private', 'r', 'project private key', Option::TYPE_STRING, true), function ($name, $value) use(&$privateKey) { $privateKey = (string) $value; }); $Command->appendParameter(new Option('public', 'b', 'project public key', Option::TYPE_STRING, true), function ($name, $value) use(&$publicKey) { $publicKey = (string) $value; }); $Command->appendParameter(new Option('user', 'u', 'user identifier', Option::TYPE_STRING, true), function ($name, $value) use(&$user) { $user = (string) $value; }); try { $Command->parse(true); $Client = new Client($publicKey, $privateKey); $Response = $Client->userCancelRecurring($user)->execute(); printf("%s\n", $Response); } catch (RequiredOptionException $Ex) { $Command->displayHelp(); }
*/ include __DIR__ . '/../vendor/autoload.php'; use alxmsl\AppStore\Client; use alxmsl\AppStore\Response\iOS6\RenewableStatus; use alxmsl\AppStore\Response\iOS6\Status; use alxmsl\AppStore\Response\iOS7\ResponsePayload; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; $isSandbox = false; $password = ''; $receipt = ''; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('password', 'p', 'subscription password', Option::TYPE_STRING), function ($name, $value) use(&$password) { $password = $value; }); $Command->appendParameter(new Option('receipt', 'r', 'receipt data (base 64)', Option::TYPE_STRING, true), function ($name, $value) use(&$receipt) { $receipt = $value; }); $Command->appendParameter(new Option('test', 't', 'use sandbox', Option::TYPE_BOOLEAN), function ($name, $value) use(&$isSandbox) { $isSandbox = $value; }); try { $Command->parse(true); $AppStore = new Client(); $AppStore->setSandbox($isSandbox); if (!empty($password)) { $AppStore->setPassword($password); } $Response = $AppStore->verifyReceipt($receipt);
* * Script for Google API authorization * @author alxmsl */ include __DIR__ . '/../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; use alxmsl\Google\AndroidPublisher\InAppProducts\Client; $accessToken = ''; $packageName = ''; $productId = ''; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('access', 'a', 'access token', Option::TYPE_STRING, true), function ($name, $value) use(&$accessToken) { $accessToken = $value; }); $Command->appendParameter(new Option('package', 'p', 'package name', Option::TYPE_STRING), function ($name, $value) use(&$packageName) { $packageName = $value; }); $Command->appendParameter(new Option('product', 'r', 'product id', Option::TYPE_STRING, true), function ($name, $value) use(&$productId) { $productId = $value; }); try { $Command->parse(true); $Client = new Client(); $Client->setPackage($packageName)->setAccessToken($accessToken); $Resource = $Client->get($productId); printf("%s\n", (string) $Resource); } catch (RequiredOptionException $Ex) { $Command->displayHelp();
* @author alxmsl */ include __DIR__ . '/../../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; use alxmsl\PaymentNinja\Client; $expirationMonth = 0; $expirationYear = 0; $number = ''; $securityCode = ''; $callback = null; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('callback', 'c', 'callback JSONP function name', Option::TYPE_STRING), function ($name, $value) use(&$callback) { $callback = (string) $value; }); $Command->appendParameter(new Option('month', 'm', 'expiration month', Option::TYPE_STRING, true), function ($name, $value) use(&$expirationMonth) { $expirationMonth = (int) $value; }); $Command->appendParameter(new Option('number', 'n', 'card number', Option::TYPE_STRING, true), function ($name, $value) use(&$number) { $number = (string) $value; }); $Command->appendParameter(new Option('public', 'b', 'project public key', Option::TYPE_STRING, true), function ($name, $value) use(&$publicKey) { $publicKey = (string) $value; }); $Command->appendParameter(new Option('security', 's', 'card security code', Option::TYPE_STRING, true), function ($name, $value) use(&$securityCode) { $securityCode = (string) $value; }); $Command->appendParameter(new Option('year', 'y', 'expiration year', Option::TYPE_STRING, true), function ($name, $value) use(&$expirationYear) { $expirationYear = (int) $value;
$ip = ''; $orderId = ''; $price = 0.0; $privateKey = ''; $publicKey = ''; $recurring = null; $recurringInterval = null; $recurringTrial = null; $remember = null; $url = ''; $user = ''; $verifyCard = null; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('attributes', 'a', 'custom attributes (JSON)', Option::TYPE_STRING), function ($name, $value) use(&$attributes) { $attributes = json_decode($value, true); }); $Command->appendParameter(new Option('currency', 'c', 'currency code (ISO 4217)', Option::TYPE_STRING, true), function ($name, $value) use(&$currency) { $currency = (string) $value; }); $Command->appendParameter(new Option('description', 'd', 'product description', Option::TYPE_STRING, true), function ($name, $value) use(&$description) { $description = (string) $value; }); $Command->appendParameter(new Option('interval', 'n', 'automatic recurring interval in days (if not set or set to 0, then only manual recurring will be active)', Option::TYPE_STRING), function ($name, $value) use(&$recurringInterval) { $recurringInterval = (int) $value; }); $Command->appendParameter(new Option('ip', 'i', 'user ip address', Option::TYPE_STRING, true), function ($name, $value) use(&$ip) { $ip = (string) $value; }); $Command->appendParameter(new Option('order', 'o', 'merchant\'s order ID that will be returned back in a callback', Option::TYPE_STRING, true), function ($name, $value) use(&$orderId) { $orderId = (int) $value;
* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Usage example * @author alxmsl * @date 10/22/12 */ // Firstly include base class include '../source/Autoloader.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Option; // Create command instance $Command = new CommandPosix(); // Append created option for help to command $Command->appendHelpParameter('show help screen option'); // Append one required option. And... $Command->appendParameter(new Option('option', 'o', 'some option', Option::TYPE_BOOLEAN, true)); // ...just parse the command $Command->parse(); // If will exception, when required option is not set - use string below //$Command->parse(true);
use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; use alxmsl\PaymentNinja\Client; $publicKey = ''; $privateKey = ''; $user = ''; $email = ''; $ip = ''; $displayName = null; $locale = null; $phone = null; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('display', 'd', 'user\'s display name', Option::TYPE_STRING), function ($name, $value) use(&$displayName) { $displayName = (string) $value; }); $Command->appendParameter(new Option('email', 'e', 'user email address', Option::TYPE_STRING, true), function ($name, $value) use(&$email) { $email = (string) $value; }); $Command->appendParameter(new Option('ip', 'i', 'user ip address', Option::TYPE_STRING, true), function ($name, $value) use(&$ip) { $ip = (string) $value; }); $Command->appendParameter(new Option('locale', 'l', 'user\'s locale (ISO 639-1)', Option::TYPE_STRING), function ($name, $value) use(&$locale) { $locale = (string) $value; }); $Command->appendParameter(new Option('phone', 'p', 'user\'s phone number', Option::TYPE_STRING), function ($name, $value) use(&$phone) { $phone = (string) $value; }); $Command->appendParameter(new Option('private', 'r', 'project private key', Option::TYPE_STRING, true), function ($name, $value) use(&$privateKey) { $privateKey = (string) $value;
*/ include __DIR__ . '/../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; use alxmsl\Google\OAuth2\Response\Token; use alxmsl\Google\OAuth2\WebServerApplication; $clientId = ''; $clientSecret = ''; $code = ''; $redirectUri = ''; $scopes = []; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('code', 'o', 'authorization code', Option::TYPE_STRING), function ($name, $value) use(&$code) { $code = $value; }); $Command->appendParameter(new Option('client', 'c', 'client id', Option::TYPE_STRING, true), function ($name, $value) use(&$clientId) { $clientId = $value; }); $Command->appendParameter(new Option('redirect', 'r', 'redirect uri', Option::TYPE_STRING, true), function ($name, $value) use(&$redirectUri) { $redirectUri = $value; }); $Command->appendParameter(new Option('scopes', 's', 'grant scopes', Option::TYPE_STRING, true), function ($name, $value) use(&$scopes) { $scopes = explode(',', $value); }); $Command->appendParameter(new Option('secret', 'e', 'client secret', Option::TYPE_STRING, true), function ($name, $value) use(&$clientSecret) { $clientSecret = $value; }); try { $Command->parse(true);
* distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Script for Google API access token refreshing * @author alxmsl */ include __DIR__ . '/../vendor/autoload.php'; use alxmsl\Cli\CommandPosix; use alxmsl\Cli\Exception\RequiredOptionException; use alxmsl\Cli\Option; use alxmsl\Google\OAuth2\WebServerApplication; $token = ''; $Command = new CommandPosix(); $Command->appendHelpParameter('show help'); $Command->appendParameter(new Option('token', 't', 'revoked token', Option::TYPE_STRING, true), function ($name, $value) use(&$token) { $token = $value; }); try { $Command->parse(true); $Client = new WebServerApplication(); $revoked = $Client->revoke($token); if ($revoked) { printf("token %s revoked\n", $token); } else { printf("token %s was not revoke\n", $token); } } catch (RequiredOptionException $Ex) { $Command->displayHelp(); }