List of usage examples for org.springframework.social.facebook.web RealTimeUpdate getObject
public String getObject()
From source file:org.springframework.social.facebook.web.RealTimeUpdateController.java
/** * Receives an update from Facebook's real-time API. * @param subscription The subscription name. * @param payload The request body payload. * @param signature The SHA1 signature of the request. * @return a String with the response back to Facebook * @throws Exception an Exception if anything goes wrong while processing the update */// w w w . j av a 2 s .com @RequestMapping(value = "/{subscription}", method = POST) public @ResponseBody String receiveUpdate(@PathVariable("subscription") String subscription, @RequestBody String payload, @RequestHeader(X_HUB_SIGNATURE) String signature) throws Exception { // Can only read body once and we need it as a raw String to calculate the signature. // Therefore, use Jackson ObjectMapper to give us a RealTimeUpdate object from that raw String. RealTimeUpdate update = new ObjectMapper().readValue(payload, RealTimeUpdate.class); if (verifySignature(payload, signature)) { logger.debug("Received " + update.getObject() + " update for '" + subscription + "'."); for (UpdateHandler handler : updateHandlers) { handler.handleUpdate(subscription, update); } } else { logger.warn("Received an update, but signature was invalid. Not delegating to handlers."); } return ""; }