Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: "WiFi Button"
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2024-09-27 19:30:04
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* book meeting to the mail which is */
- /* genesisestatesolutions@gmail.com by mailing the */
- /* business name and city and its type */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <EasyButton.h> //https://github.com/evert-arias/EasyButton
- #include <FacebookApi.h> //https://github.com/witnessmenow/arduino-facebook-api
- #include <ESP8266WiFi.h> // Include for WiFi functionality
- #include <WiFiClientSecure.h> // Include for secure WiFi client
- #include <SMTPClient.h> // Include for sending emails (make sure to have a suitable library for SMTP)
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void sendEmail(const String& businessName, const String& city, const String& type);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t ChatNow_PushButton_PIN_D2 = 2;
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- // Initialize the EasyButton object with the pin number and default parameters
- EasyButton chatNowButton(ChatNow_PushButton_PIN_D2);
- // Initialize WiFi client and Facebook API object
- WiFiClientSecure client;
- String FACEBOOK_ACCESS_TOKEN = "BIG_LONG_ACCESS_TOKEN"; // Replace with your actual access token
- FacebookApi api(client, FACEBOOK_ACCESS_TOKEN); // Initialize FacebookApi with client and access token
- // SMTP client for sending emails
- SMTPClient smtpClient("smtp.example.com", "your_email@example.com", "your_email_password"); // Replace with your SMTP server and credentials
- /****** FUNCTION DEFINITIONS *****/
- void setup(void)
- {
- // Start serial communication for debugging
- Serial.begin(115200);
- // Initialize the button
- chatNowButton.begin();
- // Set the button pin mode to INPUT_PULLUP
- pinMode(ChatNow_PushButton_PIN_D2, INPUT_PULLUP);
- // Connect to WiFi
- WiFi.mode(WIFI_STA);
- WiFi.disconnect();
- delay(100);
- Serial.print("Connecting to WiFi...");
- WiFi.begin("your_ssid", "your_password"); // Replace with your actual SSID and password
- while (WiFi.status() != WL_CONNECTED) {
- delay(500);
- Serial.print(".");
- }
- Serial.println("WiFi connected");
- }
- void loop(void)
- {
- // Read the button state
- chatNowButton.read();
- // Check if the button is pressed
- if (chatNowButton.isPressed()) {
- // Define business details
- String businessName = "Your Business Name"; // Replace with actual business name
- String city = "Your City"; // Replace with actual city
- String type = "Your Business Type"; // Replace with actual business type
- // Send email to book a meeting
- sendEmail(businessName, city, type);
- }
- // Example: Get total friends count
- int friendsCount = api.getTotalFriends();
- if (friendsCount >= 0) {
- Serial.print("Facebook Friends: ");
- Serial.println(friendsCount);
- } else {
- Serial.println("Error getting friends count");
- }
- }
- // Function to send email
- void sendEmail(const String& businessName, const String& city, const String& type) {
- String subject = "Meeting Request from " + businessName;
- String body = "Business Name: " + businessName + "\nCity: " + city + "\nType: " + type;
- // Send the email
- if (smtpClient.send("genesisestatesolutions@gmail.com", subject, body)) {
- Serial.println("Email sent successfully!");
- } else {
- Serial.println("Failed to send email.");
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement