-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Send SMS messages to your Free Mobile device via any internet-connected device.
For example, you can configure a control panel or storage connected to your home network to send a notification to your mobile phone when an event occurs.
Note
SMS notifications require an API key. If you are not already registered, sign up for a Free Mobile account.
You first need to enable the SMS notifications in your subscriber account. This will give you an identification key allowing access to the Free Mobile API.
Download the latest JAR file of Free Mobile for Java from the GitHub releases:
https://github.com/cedx/free-mobile.java/releases/latest
Add it to your class path. Now in your Java code, you can use:
import io.belin.free_mobile.*;
This library provides the Client
class, which allow to send SMS messages to your mobile phone by using the sendMessage()
method:
import io.belin.free_mobile.Client;
class Program {
public static void main(String... args) {
try {
var client = new Client("your account identifier", "your API key");
client.sendMessage("Hello World from Java!");
System.out.println("The message was sent successfully.");
}
catch (Client.Exception e) {
System.err.println("An error occurred: " + e.getMessage());
}
}
}
The Client.sendMessage()
method throws a Client.Exception
if any error occurred while sending the message.
Warning
The text of the messages will be automatically truncated to 160 characters:
you can't send multipart messages using this library.