我已经在后端实现了播放计费 API,我成功获取了 startTime 但 lineItems->expiryTime 无法获取,不显示任何内容
require_once('autoload.php');
//purchases_products
$client = new Google_Client();
$client->setAuthConfig( 'credentials.json');
$client->addScope('https://www.googleapis.com/auth/androidpublisher');
$service = new Google_Service_AndroidPublisher($client);
$purchase = $service->purchases_subscriptionsv2->get(PACKAGE_NAME, $token);
echo $purchase->startTime;
//echo $purchase->lineItems;
echo json_encode($purchase['lineItems']);
// don't show anything with this
echo $purchase->lineItems->expiryTime;
我用它来获取 $purchase->getExpiryTimeMillis(); 请注意我使用旧版本(2.10.1)的 google-api-php-client
$packageName = 'your package name';
$productId = 'your product id';
$token = 'purchase token';
$client = new \Google_Client();
$path = 'googleApi/service.json';
$client->setAuthConfig($path);
$client->addScope('https://www.googleapis.com/auth/androidpublisher');
$service = new \Google_Service_AndroidPublisher($client);
$purchase = $service->purchases_subscriptions->get($packageName, $productId, $token);
$autoRenewing = $purchase->getAutoRenewing();
$acknowledgementState = $purchase->getAcknowledgementState();
$expiryTimeMillis = $purchase->getExpiryTimeMillis();
echo('$expiryTimeMillis: '. $expiryTimeMillis. ' | $autoRenewing:'. $autoRenewing. ' | $acknowledgementState: '. $acknowledgementState);
dd($purchase);