Twilio tells me Error - 52182 Messaging Service not specified
, so I obviously don't understand how to specificy if, even though I thought I did. The body of the Twilio debugger says Messaging service SID must be specified
I've not found anything that has helped so far on stack, so I'm chancing a question. The same goes for the Twilio docs.
$recipients = [];
foreach ($userIds as $userId) {
$user = Craft::$app->users->getUserById($userId);
$number = !empty($user->mobil);
if ($number) {
try {
$number = $twilio->lookups->v1->phoneNumbers($user->mobil)->fetch(['countryCode' => 'NO'])->phoneNumber;
$recipients[] = '{"binding_type":"sms", "address":"'.$number.'"}';
} catch (\Exception $e) {
continue;
}
}
}
$twilio = new Client('xxx', 'xxx');
$service = $twilio->notify->v1->services->create();
$twilio->notify->services($service->sid)
->notifications->create([
"toBinding" => $recipients,
"body" => $body
]);
I thought I was specifying the service sid here $twilio->notify->services($service->sid)
, but apparently I'm not.
Previously I would send one SMS at a time in a loop, but that times out due to a growing list of subscribers.
Thank you for shedding any light on this.