如果沒有我所做的 foreach,我如何大量發送給所有客戶。我只想透過 1 則訊息發送給所有人。
public function sendToMany(Request $request){ $number = getenv('TWILIO_NUMBER'); //Twilio's number $sid = getenv('TWILIO_ACCOUNT_SID');////////////////////// $token = getenv('TWILIO_AUTH_TOKEN'); // API credentials // $twilio = new Client($sid, $token); ////////////////////// $otp = $request->message;//message from the form $receiver = array("+xxxxxxxxxxxx", "+xxxxxxxxxxxx", "+xxxxxxxxxxxx"); foreach ($receiver as $receiver_number){ $message = $twilio->messages ->create("whatsapp:".$receiver_number, // to array( "from" => "whatsapp:".$number, "body" => $otp //message to send ) ); }//end of for loop }//end of method
P粉7576405042024-01-29 12:15:14
沒有用於使用 Twilio API 透過 WhatsApp 發送訊息的批次 API。我們建議您循環遍歷您的數字,就像您在這裡所做的那樣,或者循環遍歷併排隊獨立發出 API 請求的後台作業。