1

我有一个 android 应用程序,它使用“Google Play In-app Billing”库在应用程序内购买。

我读过最好使用购买状态 API(Google Play Android Developer API v1.1)验证后端服务器中的购买。

我找到了一个关于如何获取刷新令牌、如何使用它来获取访问令牌以及如何使用 API 的示例。

HttpHost proxy = new HttpHost("10.12.54.8", 8080, "http");

HttpClient client = new DefaultHttpClient();
client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
ApacheHttpTransport HTTP_TRANSPORT = new ApacheHttpTransport(client);

JsonFactory JSON_FACTORY = new JacksonFactory();   

TokenResponse tokenResponse = new TokenResponse();        
tokenResponse.setAccessToken(accessToken);
tokenResponse.setRefreshToken(refreshToken);
tokenResponse.setExpiresInSeconds(3600L);
tokenResponse.setScope("https://www.googleapis.com/auth/androidpublisher/v1.1/applications");
tokenResponse.setTokenType("Bearer");

HttpRequestInitializer credential = new GoogleCredential.Builder().setTransport(HTTP_TRANSPORT).setJsonFactory(JSON_FACTORY)
                .setClientSecrets(GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET).build().setFromTokenResponse(tokenResponse);

AndroidPublisher publisher = new AndroidPublisher.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).setApplicationName(GOOGLE_PRODUCT_NAME).build(); 

AndroidPublisher.Inapppurchases purchases = publisher.inapppurchases();
Get get = purchases.get(GOOGLE_PACKAGE_NAME, ITEM_ID, purchaseToken);
InappPurchase purch = get.execute();

但我收到 404 Not Found。为什么?

提前致谢。

4

0 回答 0