【发布时间】:2013-06-21 08:30:37
【问题描述】:
我有一个 Android 应用程序,它使用“Google Play 应用内结算”库进行应用内购买。
我读到最好使用购买状态 API (Google Play Android Developer API v1.1) 在后端服务器中验证购买。
我找到了一个关于如何获取刷新令牌、如何使用它来获取访问令牌以及如何使用 API 的示例。
System.getProperties().put("http.proxyHost", "10.12.54.8");
System.getProperties().put("http.proxyPort", "8080");
HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
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();
但我无法连接到谷歌,可能是因为我在代理后面。我在使用这些类时不知道如何配置代理设置。
得到的错误是:
java.net.SocketTimeoutException: 连接超时
请帮忙!
【问题讨论】:
标签: android proxy in-app-purchase in-app-billing proxy-server