Heim > Fragen und Antworten > Hauptteil
Wie kann ich ohne die von mir durchgeführte Foreach-Aktion eine Massensendung an alle Kunden senden? Ich möchte es nur in einer Nachricht an alle senden.
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 请求的后台作业。