Class SendingUtils


  • public class SendingUtils
    extends java.lang.Object
    Class provides helper methods for sending Whatsapp messages
    Author:
    katusiimeconrad
    • Constructor Summary

      Constructors 
      Constructor Description
      SendingUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static void handleSend​(java.lang.String accessToken, org.apache.http.client.fluent.Request request, java.lang.String body)
      Intermediate Method to set required Headers
      static void send​(java.lang.String to, java.lang.String fromNumberID, java.lang.String accessToken)
      Sends a test message to a given recipient
      static void send​(java.lang.String to, java.lang.String message, java.lang.String fromNumberID, java.lang.String accessToken)
      Sends a message to a given number
      private static void sendRequest​(org.apache.http.client.fluent.Request request)
      Sends the request
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SendingUtils

        public SendingUtils()
    • Method Detail

      • send

        public static void send​(java.lang.String to,
                                java.lang.String message,
                                java.lang.String fromNumberID,
                                java.lang.String accessToken)
                         throws java.io.IOException
        Sends a message to a given number
        Parameters:
        to - the recipient of the message - in the format 2567xxxxxxxx
        message - the message to be sent
        fromNumberID - the numberID of the sender - obtained from Facebook
        accessToken - the Bearer access token for authentication - obtained from Facebook
        Throws:
        java.io.IOException - due to HTTP errors
      • send

        public static void send​(java.lang.String to,
                                java.lang.String fromNumberID,
                                java.lang.String accessToken)
                         throws java.io.IOException
        Sends a test message to a given recipient
        Parameters:
        to - the phone number (format: 2567xxxxxxxxx) receiving the message
        fromNumberID - the numberId for the sender - obtained from Facebook
        accessToken - the authorization token - obtained from Facebook
        Throws:
        java.io.IOException
      • handleSend

        private static void handleSend​(java.lang.String accessToken,
                                       org.apache.http.client.fluent.Request request,
                                       java.lang.String body)
                                throws java.io.IOException
        Intermediate Method to set required Headers
        Parameters:
        accessToken -
        request -
        body -
        Throws:
        java.io.IOException - HTTP exceptions
      • sendRequest

        private static void sendRequest​(org.apache.http.client.fluent.Request request)
                                 throws java.io.IOException
        Sends the request
        Parameters:
        request -
        Throws:
        java.io.IOException - HTTP exceptions