@Controller @RequestMapping(value="/realtime/facebook") public class RealTimeUpdateController extends Object
| Constructor and Description |
|---|
RealTimeUpdateController(Map<String,String> tokens,
List<UpdateHandler> updateHandlers,
String applicationSecret)
Constructs a RealTimeUpdateController.
|
| Modifier and Type | Method and Description |
|---|---|
String |
receiveUpdate(String subscription,
String payload,
String signature)
Receives an update from Facebook's real-time API.
|
String |
verifySubscription(String subscription,
String challenge,
String verifyToken)
Handles subscription verification callback from Facebook.
|
@Inject public RealTimeUpdateController(Map<String,String> tokens, List<UpdateHandler> updateHandlers, String applicationSecret)
tokens - A map of subscription names to verification tokens.updateHandlers - A list of UpdateHandler implementations to handle incoming updates.applicationSecret - the application's Facebook App Secret@RequestMapping(value="/{subscription}", method=GET, params="hub.mode=subscribe") @ResponseBody public String verifySubscription(@PathVariable(value="subscription") String subscription, @RequestParam(value="hub.challenge") String challenge, @RequestParam(value="hub.verify_token") String verifyToken)
subscription - The subscription name.challenge - A challenge that Facebook expects to be returned.verifyToken - A verification token that must match with the subscription's token given when the controller was created.@RequestMapping(value="/{subscription}", method=POST) @ResponseBody public String receiveUpdate(@PathVariable(value="subscription") String subscription, @RequestBody String payload, @RequestHeader(value="X-Hub-Signature") String signature) throws Exception
subscription - The subscription name.payload - The request body payload.signature - The SHA1 signature of the request.Exception - an Exception if anything goes wrong while processing the update