public Response(WS.HttpResponse response) { this.httpResponse = response; JSONObject queryJson = JSONObject.fromObject(response.getString()); if (queryJson != null) { this.accessToken = queryJson.get("access_token").toString(); this.uid = queryJson.get("uid").toString(); this.error = null; } else { this.accessToken = null; this.uid = null; this.error = Error.oauth2(response); } }
public void unsubscribe(String user, String repository, String type) { WSRequest request = WS.url("https://api.github.com/hub"); request.authenticate(username, password); request.setParameter("hub.mode", "unsubscribe"); request.setParameter( "hub.topic", String.format("https://github.com/%s/%s/events/%s", user, repository, type)); play.libs.WS.HttpResponse response = request.post(); Logger.info("Response status : " + response.getStatus()); Logger.info("Response body : " + response.getString()); if (response.getStatus() == 204) { } else { // TODO } }