GithubHelp home page GithubHelp logo

vladyslavkvaskov / sms-sender-fetchapi-ajax Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 18 KB

In this repository, you will learn how fetch API can be used to send SMS. The demo can send SMS only to those phone numbers that belong to such carriers as AT&T and Verizon.

Home Page: https://marinmover.com/fetchAPI/sms-sender/

HTML 19.74% CSS 23.72% JavaScript 56.54%

sms-sender-fetchapi-ajax's Introduction

Welcome to the SMS-sender-fetchAPI repository!

Before starting you should learn about sending SMS via email. If I wanted to send SMS to +1(530)301-6604, I would need to know which carrier this number belongs to. It's the AT&T number. Then I would need to know the gateway that needs to be used to send SMS/MMS. In the case of AT&T, the email address would be [email protected]. Here is the list of gateways.

Here is the demo. The message in the demo is sent only to AT&T and VERIZON carriers.

Here is a code that could be used to send SMS/MMS to 5303016604 or any other phone number

fetch('https://marinmover.com/email_sender/php/email_sender.php', {
      method: 'POST',
      'Accept': 'application/json',
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
      body: 'email_message=' + JSON.stringify({
            'mail_to': '[email protected]',
            'mail_subject': 'Test1',
            'mail_message': 'Great. It works!'
      })
  }).then(response => response.json()).then(data => {
      if (data.result == 'success') {
          document.body.innerHTML = `SMS was successfully sent to 5303016604`;
          console.log(data);
      }
      else
          document.body.innerHTML = 'Error sending a message!';

  }).catch(err => {
    console.log(err);
  });

Thanks for visiting this repository

In the .htaccess file on the server, I wrote

Header set Access-Control-Allow-Origin "*"

so you can access everything on the https://marinmover.com/ using fetch API. You can access https://marinmover.com/email_sender/php/email_sender.php using fetch API without getting the following error:

Access to fetch at 'https://marinmover.com/' from origin 'https://your-origin.com' has been blocked by CORS policy: 
No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, 
set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.