“Senden Sie SMS mit Twilio” Code-Antworten

Senden Sie SMS mit Twilio im Knoten

const smsSid = process.env.SMS_SID
const smsAuthToken = process.env.SMS_AUTH_TOKEN
const twilio = require('twilio')(smsSid, smsAuthToken, {
    lazyLoading: true,
});

async sendBySms(phone, otp) {
        return await twilio.messages.create({
            to: phone,
            from: process.env.SMS_FROM_NUMBER,
            body: `Your codershouse OTP is ${otp}`,
        });
    }
Shirshak kandel

Twilio SMS zeigt keine Absendungsnummer an

Why do some SMS recipients see a Sender ID that is not my Twilio number?
Sender ID change may occur when you send messages from a Twilio number that is not local to your recipients, for example using a US Twilio number to send SMS to Polish mobile users. This is often done to comply with local regulations, or to ensure the highest possible delivery rate for your messages.

Sender ID change will not occur when you send messages using a Twilio number from the same country as the recipient, for example using a Polish Twilio number to send SMS to a Polish mobile user.

Sender ID change does not negatively affect delivery quality, however it means that replies from recipients will not be routed back to your Twilio number.

If you need to receive SMS replies from your users, please use a Twilio phone number or short code from the same country as your recipients. This will ensure Sender ID is preserved. For more info, see Receiving Two-Way SMS and MMS Messages with Twilio
florinrelea

Senden Sie SMS mit Twilio

function send_sms($number,$body)
{
    $ID = '1234567890abcdef1234567890abcdef12';
    $token = '1234567890abcdef1234567890abcdef';
    $service = 'AB1234567890abcdef1234567890abcdef';
    $url = 'https://api.twilio.com/2010-04-01/Accounts/' . $ID . '/Messages.json';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);

    curl_setopt($ch, CURLOPT_HTTPAUTH,CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_USERPWD,$ID . ':' . $token);

    curl_setopt($ch, CURLOPT_POST,true);
    curl_setopt($ch, CURLOPT_POSTFIELDS,
        'To=' . rawurlencode('+' . $number) .
        '&MessagingServiceSid=' . $service .         // this is optionnel
        //'&From=' . rawurlencode('+18885550000') .  // this is required
        '&Body=' . rawurlencode($body));

    $resp = curl_exec($ch);
    curl_close($ch);
    return json_decode($resp,true);
}

/*
$ID and $token can be found under SMS / Dashboard / 'Show API Credentials' https://www.twilio.com/console/sms/dashboard

(Optional) $service can be found under SMS / Messaging Services / 'SID' https://www.twilio.com/console/sms/services

Comment out 'MessagingServiceSid=' and uncomment 'From=' to use direct sending from a single phone number

Finally, key information can be found buried in the kb here https://www.twilio.com/docs/sms/send-messages#send-a-message-with-an-image-url

*/
Hichem from Tunisia

Ähnliche Antworten wie “Senden Sie SMS mit Twilio”

Fragen ähnlich wie “Senden Sie SMS mit Twilio”

Weitere verwandte Antworten zu “Senden Sie SMS mit Twilio” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen