我使用的是流明版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.
}