Google_Client收据验证:在\ vendor \ guzzlehttp \ guzzle \ src \ Client.php第147行找不到类'GuzzleHttp \ Psr7 \ UriResolver'

时间:2017-07-06 06:07:06

标签: php laravel receipt-validation lumen-5.3

我使用的是流明版Laravel Framework版Lumen(5.3.3)(Laravel Components 5.3。*)。以下是我的代码。但抛出异常:

  

类'GuzzleHttp \ Psr7 \ UriResolver'找不到\ vendor \ guzzlehttp \ guzzle \ src \ Client.php第147行。

代码:

$applicationName = 'xxx';
$configLocation = storage_path() . '/receiptValidation/GooglePlayAndroidDeveloper-7cb840b98626.json';
$scope = ['https://www.googleapis.com/auth/androidpublisher'];
$packageName = 'xxxxx';
$productId = 'xxxxx';
$purchaseToken = 'xxxxx';

$client = new \Google_Client();
$client->setApplicationName($applicationName);
$client->setAuthConfig($configLocation);
$client->setScopes($scope);

$validator = new PlayValidator(new \Google_Service_AndroidPublisher($client));

try {
$response = $validator->setPackageName($packageName)
    ->setProductId($productId)
    ->setPurchaseToken($purchaseToken)
    ->validatePurchase();
} catch (Exception $e) {
    var_dump($e->getMessage());
    // example message: Error calling GET ....: (404) Product not found for this application.
}

0 个答案:

没有答案