Skip to content

Instantly share code, notes, and snippets.

Created January 9, 2018 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/fadf17c88e636c75e879dfa2b95fd041 to your computer and use it in GitHub Desktop.
Save anonymous/fadf17c88e636c75e879dfa2b95fd041 to your computer and use it in GitHub Desktop.
Facebook Messenger Handler Java
********************
Facebook Messenger Handler Java >>>
********************
http://shurll.com/bz4bt
(Copy & Paste link)
********************
Good, solid and simple library that covers my need. We are using Jackson's ObjectMapper to serialize and deserialize request bodies. spring-bot select the Category: 'Apps for Messenger' click the 'Create App ID' button Section 'Token Generation': Select your created FB Page copy the 'Page Access Token' to the clipboard copy it to your application.yml navigate to 'Dashboard' copy the 'App Secret' to the clipboard copy it to your application.yml use a randomly generated string as 'Verify Token' deploy you app, and copy your public HTTPS URL (callback url) navigate back to 'Messenger' Section 'Webhooks': Click the 'Setup Webhooks' button past the Callback URL and your verify token select the following Subscription Fields: messages, messagingpostbacks, messagingoptins, messagedeliveries, messagereads, messageechoes click the 'Verify and Save' button Section 'Webhooks': Select your created FB Page to subscribe your webhook to the page events click the 'Subscribe' button . Using a no argument constructor should be sufficient. src Rename ReplyYes to MessageYes Sep 26, 2017 .gitignore Initial commit of the Facebook client Oct 10, 2016 LICENSE Initial commit Oct 9, 2016 README.md Rename ReplyYes to MessageYes Sep 26, 2017 pom.xml Add Chris back Sep 26, 2017 README.md Facebook Messenger API Client This is a Java client for the Facebook Messenger API. GET /callback: It looks for the Verify Token and respond with the challenge sent in the verification request. Log in Register What's new Search Search Search titles only By: Search Advanced search . The constructor also, initialize the MessengerReceiveClient that delegates, based on inbound event types (text, attachement .) the processing to the adequate handler:. By continuing to use this site, you are agreeing to our use of cookies. Reload to refresh your session. Skip to content Features Business Explore Marketplace Pricing This repository Sign in or Sign up . Consequently, POJO names and properties closely resemble API object and property names. RequestMapping(method = RequestMethod.GET) public ResponseEntity verifyWebhook(RequestParam("hub.mode") final String mode, RequestParam("hub.verifytoken") final String verifyToken, RequestParam("hub.challenge") final String challenge) { logger.debug("Received Webhook verification request - mode: {} verifyToken: {} challenge: {}", mode, verifyToken, challenge); try { return ResponseEntity.ok(this.receiveClient.verifyWebhook(mode, verifyToken, challenge)); } catch (MessengerVerificationException e) { logger.warn("Webhook verification failed: {}", e.getMessage()); return ResponseEntity.status(HttpStatus.FORBIDDEN).body(e.getMessage()); } } RequestMapping(method = RequestMethod.POST) public ResponseEntity handleCallback(RequestBody final String payload, RequestHeader("X-Hub-Signature") final String signature) { logger.debug("Received Messenger Platform callback - payload: {} signature: {}", payload, signature); try { this.receiveClient.processCallbackPayload(payload, signature); logger.debug("Processed callback payload successfully"); return ResponseEntity.status(HttpStatus.OK).build(); } catch (MessengerVerificationException e) { logger.warn("Processing of callback payload failed: {}", e.getMessage()); return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); } } . As such, a single instance of the client can be used to handle message correspondence for many Facebook pages at the same time. Security CheckPlease enter the text belowCan't read the text above?Try another text or an audio captchaEnter the text you see above.Why am I seeing this?Security CheckThis is a standard security test that we use to prevent spammers from creating fake accounts and spamming users.Submit.. With all that done, Now you can play with your chatbot!. Xenforo Theme by XenMake Contact us Terms and rules Help Home .. Last month I've joined the Facebook DevC family as DevC Casablanca Lead. Home . That will use the v2.6 Facebook Messenger end point. Developer Circle is a community supported by Facebook, and aims creating active communities for developers around the world to access information, share knowledge, and collaborate with other developers. 2017 Powered by Android Modded Apk Games Collection No Root . Please try refreshing and contact us if the problem persists. While youre testing your bot, only you and other Page admins can message with the bot directly. It's called Messenger4J. The controller has also 2 endPoints:. It contains one Controller class CallBackHandler which obviously handle all communication coming from WebHook. That's all, hopefully youve learned a thing or two about how to build a simple java based chat bot for Facebook Messenger.. 2018 GitHub, Inc. For more information about the API, please refer to Facebook's developer documentation: This client is still a work in progress. The CallBackHandler constructor takes 2 parameters:. The code source is available on github. FacebookMessengerClient.deserializeCallback deserializes inbound request bodies into POJOs found in com.messageyes.facebook.messenger.bean. Menu Home Home What's new Latest activity Authors Forums New posts Search forums What's new New posts New profile posts Latest activity Members Registered members Current visitors New profile posts Search profile posts Chat 1 Latest activity Register Menu 5a02188284
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment