Plivo
    
    
      
    
    
      
      จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
    
    
      
      บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
    
  
    
  
      
    
  
  
  
  
  
    
    
    
  
  
    
    
    
ส่งข้อความ SMS
/**
 * An example of sending SMS messages from Google Ads Scripts using Plivo.
 * See: https://developers.google.com/google-ads/scripts/docs/features/third-party-apis#basic_authentication_samples
 * for full details on configuration.
 */
// Supply an email address: If for some reason your Plivo account
// details become invalid or change, this will be used to make sure
// you are notified of failure.
const EMAIL_ADDRESS = 'INSERT_EMAIL_ADDRESS';
// The number you wish messages to appear to originate from. Must be registered
// with Plivo.
const PLIVO_SRC_PHONE_NUMBER = 'INSERT_SRC_PHONE_NUMBER';
// Account details, see: https://manage.plivo.com/dashboard/
const PLIVO_ACCOUNT_AUTHID = 'INSERT_ACCOUNT_AUTHID';
const PLIVO_ACCOUNT_AUTHTOKEN = 'INSERT_ACCOUNT_AUTHTOKEN';
/**
 * Builds an SMS message for sending with Plivo and sends the message.
 * @param {string} dstPhoneNumber The destination number. This is a string as
 *     telephone numbers may contain '+'s or be prefixed with '00' etc.
 * @param {string} message The text message to send.
 */
function sendPlivoSms(dstPhoneNumber, message) {
  const request =
      buildPlivoMessageRequest(dstPhoneNumber, message);
  sendSms(request);
}
/**
 * Send an SMS message
 * @param {!SmsRequest} request The request object to send
 */
function sendSms(request) {
  const retriableErrors = [429, 500, 503];
  for (let attempts = 0; attempts < 3; attempts++) {
    const response = UrlFetchApp.fetch(request.url, request.options);
    const responseCode = response.getResponseCode();
    if (responseCode < 400 || retriableErrors.indexOf(responseCode) === -1) {
      break;
    }
    Utilities.sleep(2000 * Math.pow(2, attempts));
  }
  if (responseCode >= 400 && EMAIL_ADDRESS) {
    MailApp.sendEmail(
        EMAIL_ADDRESS, 'Error sending SMS Message from Google Ads Scripts',
        response.getContentText());
  }
}
/**
 * Builds a SMS request object specific for the Plivo service.
 * @param {string} recipientPhoneNumber Destination number including country
 *     code.
 * @param {string} textMessage The message to send.
 * @return {SmsRequest}
 */
function buildPlivoMessageRequest(recipientPhoneNumber, textMessage) {
  if (!recipientPhoneNumber) {
    throw Error('No "recipientPhoneNumber" specified in call to ' +
        'buildPlivoMessageRequest. "recipientPhoneNumber" cannot be empty');
  }
  if (!textMessage) {
    throw Error('No "textMessage" specified in call to ' +
        'buildPlivoMessageRequest. "textMessage" cannot be empty');
  }
  const plivoUri =
      `https://api.plivo.com/v1/Account/${PLIVO_ACCOUNT_AUTHID}/Message/`;
  const authHeader = 'Basic ' +
      Utilities.base64Encode(
          PLIVO_ACCOUNT_AUTHID + ':' + PLIVO_ACCOUNT_AUTHTOKEN);
  const options = {
    muteHttpExceptions: true,
    method: 'POST',
    headers: {'Authorization': authHeader, 'Content-Type': 'application/json'},
    payload: JSON.stringify({
      src: PLIVO_SRC_PHONE_NUMBER,
      dst: recipientPhoneNumber,
      text: textMessage
    })
  };
  return {url: plivoUri, options: options};
}
  
  
  
  
    
  
 
  
    
      
      
    
    
      
    
    
  
       
    
    
      
    
  
  
  เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
  อัปเดตล่าสุด 2025-08-21 UTC
  
  
  
    
      [[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-08-21 UTC"],[],[]]