SMS from the site. How to add?

Almost all sites have registration via SMS. How can I add this feature to my site?

Answer 1, authority 100%

  1. program the formation of a secret number (such as code 1234)
  2. send this code via API to the client on the phone, for example via
  3. save this code to the database for this client
  4. when the client enters the code from the phone, compare whether it is the one in the database.
  5. if that one – then you can let in – the person confirmed the validation.