esraa_syam

send sms

Nov 26th, 2023
1,493
0
Never
9
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const twilio = require("twilio")(sid, auth_token);
  2.  
  3. const sendSMS = asyncHandler(async (req, res) => {
  4.   try {
  5.     const message = await twilio.messages.create({
  6.       from: "+16415524124",
  7.       to: req.body.phoneNumber,
  8.       body: "This is a testing message",
  9.     });
  10.  
  11.     console.log("Message has been sent:", message.sid);
  12.  
  13.     res.status(200).json({ success: true, message: "SMS sent successfully" });
  14.   } catch (error) {
  15.     console.error("Error sending SMS:", error);
  16.  
  17.     res.status(500).json({ success: false, error: "Failed to send SMS" });
  18.   }
  19. });
Advertisement
Comments
  • tidbit
    2 years
    # text 0.04 KB | 0 0
    1. Just testing the comment system. ignore me.
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment