Java
This tutorial provides you with a step-by-step walkthrough of how to build a ‘Doctor’s Appointment App’ to send appointment reminders via SMS using Live Link 365.
This is not a production-ready application. Please take your time to enhance it for production so that it meets your specific business requirements.
The main panel on the right highlights the right piece of code for each step.Steps
Create the Java class for Doctor
using the doctorID
, doctorName
and specialization
:
- doctorID: Integer
- doctorName: String
- specialization: String
Doctor
class
Create the Java class for Patient
using the patientID
and patientName
:
- patientID: Integer
- patientName: String
Patient
class
Create the Java class for Specialization
using the specializationID
and specializationName
:
- specializationID: Integer
- specializationName: String
Specialization
class
Create the Java class for Appointment
using the Doctor
, Patient
, Specialization
and Date
class objects.
Create the getter/setter methods to access the attributes of the Appointment
class
The config.properties file acts as a temporary storage for records and holds key information such as: patient’s name, doctor’s name, specialization, date, time, and so on.
The properties file can be replaced by the database, which holds the employee information
This is the executable Java class which contains the main method. It reads the properties defined in the config.properties
file.
Compile and Run this file as a Java Application through eclipse
Before you can use the API for sending SMS, you have to fetch an authentication token by providing:
- App Key
- App Secret
getAccessToken()
method will take the App Key and App Secret and combine them into a Base64 string, which will then be sent to the /api/oauth/token
endpoint for generating the authentication token For this step we have created two methods:
getAccessToken()
: This is the method that takes your App Key and App Secret.postForAccessToken()
: A method for making the POST request
After parsing the JSON string, you should return the access_token
field from the JSON response
On this step we create the methods for sending an SMS, there are two parts to it:
- The
post()
method: makes an HTTP POST request, given the url and a string with the data in a JSON format - The
sendSMS()
takes your message string, your origin phone number, the destination phone number and the Authentication Token generated by the method from a previous step
Now we finally call the main function, connecting the booking classes to the sending API.
Replace in the code:
- appKey: An app key created for your application
- appSecret: An app secret created for your application
- destinationNumber: The phone number you want to send the message to
MessageHandler.sendSMS()
method
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|