2017-07-14 73 views
1

我正在開發一個程序,在該程序中,我將向我的Twilio號碼發送一條消息,並將消息發送給一羣人。我想要從SQL數據庫中讀取數字(以便人們可以通過PHP在網站上註冊)或通過Google表格電子表格讀取數字。我真的不知道從哪裏開始,並想知道是否可以從專業人士那裏獲得一些意見。大衆短信程序

謝謝!

安東尼

回答

2

Twilio開發人員傳道這裏。

如果您要尋找的是使用Google電子表格,我們實際上有一個非常全面的教程,介紹如何使用Google電子表格與PHP here

但要點如下:

  1. 啓用電子表格進行編程訪問
  2. 開始通過您的記錄讀取來自它和循環中的數據。

通過您的記錄循環可以像這樣一樣簡單:

// Get our spreadsheet 
$spreadsheet = (new Google\Spreadsheet\SpreadsheetService) 
    ->getSpreadsheetFeed() 
    ->getByTitle('Phone Numbers'); 

// Get the first worksheet (tab) 
$worksheets = $spreadsheet->getWorksheetFeed()->getEntries(); 
$worksheet = $worksheets[0]; 

$listFeed = $worksheet->getListFeed(); 

/** @var ListEntry */ 
foreach ($listFeed->getEntries() as $entry) { 
    $phone = $entry->getValues(); 
} 

在上述循環,你也可以使用Twilio REST API開始與Twilio發送短信如下:

$短信= $客戶 - >帳戶 - >消息 - >創建(

// the number we are sending to - Any phone number 
$phone, 

array(
    // Step 6: Change the 'From' number below to be a valid Twilio number 
    // that you've purchased 
    'from' => "YOUR_NUMBER", 

    // the sms body 
    'body' => "Hey $name, Monkey Party at 6PM. Bring Bananas!" 
) 
); 

所以它只是一個使用兩者結合起來的問題。你可以看莫關於用PHP發送郵件here

希望這可以幫助你出

+0

所以你會使用工作表來更新聯繫人號碼和所有,正確嗎?然後爲了同時運行,每個人都會使用PHP嗎?對於所有的問題抱歉,我對PHP編碼很陌生。 –

+0

你可以讓他們都在同一個程序中。 –