| 123456789101112131415161718192021222324252627282930313233343536 |
- import axios from 'axios'
- // Find your Service Plan ID and API Token at dashboard.sinch.com/sms/api/rest
- // Find your Sinch numbers at dashboard.sinch.com/numbers/your-numbers/numbers
- const SERVICE_PLAN_ID = 'a1ac863dc82e4075b816a22d8f75a9c7'
- const API_TOKEN = 'eb521456941c4fce861e254fb669f743'
- const SINCH_NUMBER = '+12085686210'
- const TO_NUMBER = '+19073414563'
- const REGION = 'us'
- const SINCH_URL = 'https://' + REGION + '.sms.api.sinch.com/xms/v1/' + SERVICE_PLAN_ID + '/batches'
- const headers = { 'Content-Type': 'application/json', Authorization: 'Bearer ' + API_TOKEN }
- const payload = JSON.stringify({
- from: SINCH_NUMBER,
- to: [TO_NUMBER],
- body: 'Programmers are tools for converting caffeine into code. We just got a new shipment of mugs! Check them out: https://tinyurl.com/4a6fxce7!'
- })
- // axios
- // .post(SINCH_URL, payload, { headers })
- // .then((response) => console.log(response.data))
- // .catch((error) => console.error('There was an error!', error.response))
- // axios
- // .get(`https://${REGION}.sms.api.sinch.com/xms/v1/${SERVICE_PLAN_ID}/inbounds`, { headers })
- // .then((response) => console.log(response.data))
- // .catch((error) => console.error('There was an error!', error.response))
- axios
- .get('http://us1.httplookup.api.sinch.com:3700/lookup?msisdn=+18583199738', {
- headers: {
- Authorization:
- 'Basic ' + btoa('a1ac863dc82e4075b816a22d8f75a9c7' + ':' + 'eb521456941c4fce861e254fb669f743')
- }
- })
- .then((response) => console.log(response.data))
- .catch((error) => console.error('There was an error!', error.response))
|