Skip to content

Commit

Permalink
update api style
Browse files Browse the repository at this point in the history
  • Loading branch information
hafidhh committed Nov 20, 2022
1 parent 2455c57 commit fb97cab
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion examples/Facebook_Message/Facebook_Message.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void setup() {
Serial.println(WiFi.localIP());

// Facebook Message
Facebook(apiKey, messsage);
facebookMessage(apiKey, messsage);
}

void loop() {
Expand Down
2 changes: 1 addition & 1 deletion examples/Telegram _Call/Telegram_Call.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void setup() {
Serial.println(WiFi.localIP());

// Telegram Call
Telegramcall(username, text);
telegramCall(username, text);
}

void loop() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void setup() {

//Telegram Message
String username = username1+"|"+username2;
Telegrammessage(username, apiKey, messsage);
telegramMessage(username, apiKey, messsage);
}

void loop() {
Expand Down
2 changes: 1 addition & 1 deletion examples/Telegram_Message/Single_User/Telegram_Message.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void setup() {
Serial.println(WiFi.localIP());

//Telegram Message
Telegrammessage(username, apiKey, messsage);
telegramMessage(username, apiKey, messsage);
}

void loop() {
Expand Down
2 changes: 1 addition & 1 deletion examples/Whatsapp_Message/Whatsapp_Message.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void setup() {
Serial.println(WiFi.localIP());

// Whatsapp Message
Whatsapp(phoneNumber, apiKey, messsage);
whatsappMessage(phoneNumber, apiKey, messsage);
}

void loop() {
Expand Down
62 changes: 31 additions & 31 deletions src/Callmebot_ESP8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @param message "textmessage"
* @returns apiKey : https://www.callmebot.com/blog/free-api-whatsapp-messages/.
*/
void Whatsapp(String phoneNumber, String apiKey, String message) {
void whatsappMessage(String phoneNumber, String apiKey, String message) {
// Data to send with HTTP POST
String url = "http://api.callmebot.com/whatsapp.php?phone=" + phoneNumber + "&apikey=" + apiKey + "&text=" + urlEncode(message);
WiFiClient client;
Expand Down Expand Up @@ -42,7 +42,7 @@ void Whatsapp(String phoneNumber, String apiKey, String message) {
* @param message "textmessage"
* @returns apiKey : https://www.callmebot.com/blog/free-api-facebook-messenger/
*/
void Facebook(String apiKey, String message) {
void facebookMessage(String apiKey, String message) {
// Data to send with HTTP POST
String url = "https://api.callmebot.com/facebook/send.php?apikey=" + apiKey + "&text=" + urlEncode(message);
WiFiClient client;
Expand All @@ -68,14 +68,15 @@ void Facebook(String apiKey, String message) {
}

/**
* CallMeBot Telegram Group Messages.
* @param apiKey "apiKey"
* CallMeBot WhatsApp Messages.
* @param username "username"
* @param apiKey "apiKey".
* @param message "textmessage"
* @returns apiKey : https://www.callmebot.com/blog/telegram-group-messages-api-easy/
* @returns apiKey : https://www.callmebot.com/blog/telegram-text-messages/
*/
void Telegramgroup(String apiKey, String message) {
void telegramMessage(String username, String apiKey, String message) {
// Data to send with HTTP POST
String url = "https://api.callmebot.com/telegram/group.php?apikey=" + apiKey + "&text=" + message;
String url = "https://api.callmebot.com/text.php?user=" + username + "&apikey=" + apiKey + "&text=" + urlEncode(message);
WiFiClient client;
HTTPClient http;
http.begin(client, url);
Expand Down Expand Up @@ -104,12 +105,9 @@ void Telegramgroup(String apiKey, String message) {
* @param message "textmessage"
* @returns apiKey : https://www.callmebot.com/blog/telegram-group-messages-api-easy/
*/
// apiKey : https://www.callmebot.com/blog/telegram-group-messages-api-easy/
// html_format : yes/no - Default: no - Optional parameter to send the message in html format or plain text. Put "yes" when you want to send "bold" text using test (url example: &html=yes)
// link_preview : yes/no - Default: no - It will enable or disable the webpage preview that is sent together with the text message when there is an URL on it.
void Telegramgroup(String apiKey, String message, String html_format) {
void telegramGroup(String apiKey, String message) {
// Data to send with HTTP POST
String url = "https://api.callmebot.com/telegram/group.php?apikey=" + apiKey + "&text=" + message + "&html=" + html_format;
String url = "https://api.callmebot.com/telegram/group.php?apikey=" + apiKey + "&text=" + message;
WiFiClient client;
HTTPClient http;
http.begin(client, url);
Expand All @@ -133,14 +131,17 @@ void Telegramgroup(String apiKey, String message, String html_format) {
}

/**
* CallMeBot Teelegram Call.
* @param username username/phone.
* @param text "textmessage".
* @return phone: Indonesia +62, Example: "+62897461238"
* CallMeBot Telegram Group Messages.
* @param apiKey "apiKey"
* @param message "textmessage"
* @returns apiKey : https://www.callmebot.com/blog/telegram-group-messages-api-easy/
*/
void Telegramcall(String username, String text) {
// apiKey : https://www.callmebot.com/blog/telegram-group-messages-api-easy/
// html_format : yes/no - Default: no - Optional parameter to send the message in html format or plain text. Put "yes" when you want to send "bold" text using test (url example: &html=yes)
// link_preview : yes/no - Default: no - It will enable or disable the webpage preview that is sent together with the text message when there is an URL on it.
void telegramGroup(String apiKey, String message, String html_format) {
// Data to send with HTTP POST
String url = "http://api.callmebot.com/start.php?user=" + username + "&text=" + text;
String url = "https://api.callmebot.com/telegram/group.php?apikey=" + apiKey + "&text=" + message + "&html=" + html_format;
WiFiClient client;
HTTPClient http;
http.begin(client, url);
Expand All @@ -151,7 +152,7 @@ void Telegramcall(String username, String text) {
// Send HTTP POST request
int httpResponseCode = http.POST(url);
if (httpResponseCode == 200){
Serial.print("Call " + username);
Serial.print("Message sent successfully");
}
else{
Serial.println("Error sending the message");
Expand All @@ -163,9 +164,15 @@ void Telegramcall(String username, String text) {
http.end();
}

void Telegramcall(String username, String text, String language, String repeat, String textcarbon, String timeout) {
/**
* CallMeBot Teelegram Call.
* @param username username/phone.
* @param text "textmessage".
* @return phone: Indonesia +62, Example: "+62897461238"
*/
void telegramCall(String username, String text) {
// Data to send with HTTP POST
String url = "http://api.callmebot.com/start.php?user=" + username + "&text=" + text + "&lang=" + language + "&rpt=" + repeat + "&cc=" + textcarbon + "&timeout=" + timeout;
String url = "http://api.callmebot.com/start.php?user=" + username + "&text=" + text;
WiFiClient client;
HTTPClient http;
http.begin(client, url);
Expand All @@ -188,16 +195,9 @@ void Telegramcall(String username, String text, String language, String repeat,
http.end();
}

/**
* CallMeBot WhatsApp Messages.
* @param username "username"
* @param apiKey "apiKey".
* @param message "textmessage"
* @returns apiKey : https://www.callmebot.com/blog/telegram-text-messages/
*/
void Telegrammessage(String username, String apiKey, String message) {
void telegramCall(String username, String text, String language, String repeat, String textcarbon, String timeout) {
// Data to send with HTTP POST
String url = "https://api.callmebot.com/text.php?user=" + username + "&apikey=" + apiKey + "&text=" + urlEncode(message);
String url = "http://api.callmebot.com/start.php?user=" + username + "&text=" + text + "&lang=" + language + "&rpt=" + repeat + "&cc=" + textcarbon + "&timeout=" + timeout;
WiFiClient client;
HTTPClient http;
http.begin(client, url);
Expand All @@ -208,7 +208,7 @@ void Telegrammessage(String username, String apiKey, String message) {
// Send HTTP POST request
int httpResponseCode = http.POST(url);
if (httpResponseCode == 200){
Serial.print("Message sent successfully");
Serial.print("Call " + username);
}
else{
Serial.println("Error sending the message");
Expand Down
30 changes: 15 additions & 15 deletions src/Callmebot_ESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@

#include "Arduino.h"

void Whatsapp(String phoneNumber, String apiKey, String message);
void Facebook(String apiKey, String message);
void Telegrammessage(String username, String apiKey, String message);
void Telegramgroup(String apiKey, String message);
void Telegramgroup(String apiKey, String message, String html_format);
void Telegramcall(String username, String Text);
void Telegramcall(String username, String Text, String language);
void Telegramcall(String username, String Text, String repeat);
void Telegramcall(String username, String Text, String textcarbon);
void Telegramcall(String username, String Text, String timeout);
void Telegramcall(String username, String Text, String language, String repeat);
void Telegramcall(String username, String Text, String language, String textcarbon);
void Telegramcall(String username, String Text, String language, String timeout);
void Telegramcall(String username, String Text, String language, String repeat, String textcarbon);
void Telegramcall(String username, String Text, String language, String repeat, String textcarbon, String timeout);
void whatsappMessage(String phoneNumber, String apiKey, String message);
void facebookMessage(String apiKey, String message);
void telegramMessage(String username, String apiKey, String message);
void telegramGroup(String apiKey, String message);
void telegramGroup(String apiKey, String message, String html_format);
void telegramCall(String username, String Text);
void telegramCall(String username, String Text, String language);
void telegramCall(String username, String Text, String repeat);
void telegramCall(String username, String Text, String textcarbon);
void telegramCall(String username, String Text, String timeout);
void telegramCall(String username, String Text, String language, String repeat);
void telegramCall(String username, String Text, String language, String textcarbon);
void telegramCall(String username, String Text, String language, String timeout);
void telegramCall(String username, String Text, String language, String repeat, String textcarbon);
void telegramCall(String username, String Text, String language, String repeat, String textcarbon, String timeout);

#endif

0 comments on commit fb97cab

Please sign in to comment.