Ejemplo n.º 1
0
 public function testGet()
 {
     $Client = new Client();
     try {
         $Client->get('');
         $this->fail();
     } catch (UnexpectedValueException $Ex) {
     }
 }
Ejemplo n.º 2
0
<?php

/**
 * 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.
 *
 * In-app products example
 * @author alxmsl
 * @date 5/28/13
 */
include '../vendor/autoload.php';
use alxmsl\Google\AndroidPublisher\InAppProducts\Client;
use alxmsl\Google\AndroidPublisher\InAppProducts\Resource as InAppProductsResource;
const PACKAGE_NAME = 'com.example.package', ACCESS_TOKEN = '4CcE5s_T0keN', PRODUCT_ID = 'com.example.package.product.1';
$Client = new Client();
$Client->setPackage(PACKAGE_NAME)->setAccessToken(ACCESS_TOKEN);
/** @var InAppProductsResource $Resource */
$Resource = $Client->get(PRODUCT_ID);
var_dump($Resource->getPrices());
Ejemplo n.º 3
0
 * 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();
}