Hi team,
How are you? I hope you all are doing good.
I am trying to send code SMS to verify the mobile number on my website www.saralfix.com. However, I am stuck. I have used 2 backend modules and 1 client-side code.
///fast2sms.js
import {fetch} from 'wix-fetch';
export function sendwithService(key, recipient, code, id) {
const url = "https://www.fast2sms.com/dev/bulk";
const headers = {
"authorization": key,
"cache-control": "no-cache",
"content-Type": "application/x-www-form-urlencoded"
};
const data = {
"sender_id": id,
"language": "english",
"route": "qt",
"numbers": "9999999999,8888888888,7777777777",
"message": "18054",
}
const request = {
"method": "post",
"headers": headers,
};
return fetch(url, request)
.then(response => response.json());
}
///sendSms.jsw
import {sendwithService} from 'backend/fast2sms';
export function sendEmail(code,recipient) {
const key = "my API key hidden for security purposes";
const id = "SRLFIX";
return sendwithService(key, id, recipient, code);
}
///page code
import {sendEmail} from 'backend/sendSms';
export function Submitgroup1_click(event) {
$w("#dataset1").onAfterSave(sendOtp);
}
function sendOtp() {
let digits = '0123456789'
let random
for (let i = 0; i < 5; i++ ) {
random += digits[Math.floor(Math.random() * 10)];
}
let code = random;
let recipient = $w("#Mobile").value;
sendEmail(code, recipient)
.then(response => console.log(response));
}
I get the following error
return:
false
status_code:
401
message:
"Sender ID Missing"
@givemeawhisky @yisrael-wix @code-queen Hi guys, I have learnt a lot from your posts. It would be great if you can spare your precious time to help me.
Why does it look like you have used the Wix code tutorial for sending an email on form submission which uses SendGrid and then tried to suit it to fix your own code etc.
https://support.wix.com/en/article/corvid-tutorial-sending-an-email-on-form-submission
That is Fast2Sms own error messages, so you will need to go back to their own support and get them to tell you where you are going wrong.
https://docs.fast2sms.com/#error-codes
sender_id - true - " FSTSMS " is the default sender id, you can create your own custom 6 digit sender id on Fast2SMS
As for your code, make sure that you are following their own API docs and using their own provided code.
https://docs.fast2sms.com/?java#get-method
https://www.fast2sms.com/help/quick-transactional-sms/
Also, there are already samples out there for Fast2Sms that you can use for examples.
https://www.quora.com/How-do-I-send-text-messages-from-a-python-script-to-a-mobile-number-if-possible-with-a-free-gateway/answer/Pratham-Anchan
@givemeawhisky I have indeed used the send email code. However I have made sure that I am following the fast2sms requirements. Everything is running smoothly however the code somehow skips the sender ID. That is why its gives a Invalid sender ID.
@givemeawhisky I was able to send the verification code through SMS. Now the problem is how can I validate the code after user input the code. Please guide me to right direction.
If you still want to use Fast2Sms, then you will have to look at implementing the quick transactional api.
https://docs.fast2sms.com/?javascript#quick-transactional-api
There has been previous posts asked about this.
https://www.wix.com/corvid/forum/community-discussion/otp-for-verification
https://www.wix.com/corvid/forum/community-discussion/sms-otp-ingratiating-in-wix-code-for-verification
https://www.wix.com/corvid/forum/community-feature-request/otp-verification-for-user-mobile-and-email
https://www.wix.com/corvid/forum/community-discussion/twilio-authy-verify-json-response
See here for the Wix Users Backend and the register function which gives a detailed code example for registering a user after third party verification.
https://www.wix.com/corvid/reference/wix-users-backend.html#register
Examples
Register a user using a 3rd party for approval
This example demonstrates a common 3rd party approval flow. The backend code calls a 3rd party function that determines whether the user will be approved or not. If approved, the register() function is called, the registration is approved programmatically, and a session token is returned to the calling client-side code. If rejected, the blockByEmail() function is called.
Plus, approve by email and approve by token.
https://www.wix.com/corvid/reference/wix-users-backend.html#approveByEmail
https://www.wix.com/corvid/reference/wix-users-backend.html#approveByToken
@givemeawhisky Thanks for this information.
In case you don’t want to share your real number I recommend you to use grizzlysms verification services https://grizzlysms.com/ . Very reliable, safe and cheap ones!
Brainmap provides services like bulk mobile messaging, VoIP, and call center solutions so companies can easily communicate with clients or staff.