无法使用Twilio批量发送短信(错误52182)

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.

I found this guide on youtube: https://www.youtube.com/watch?v=EMOYY58jyKk which seems to have solved my issues, it's not for PHP but the steps were pretty much the same.

In any case, my final code ended up like so

$notifySid = 'ISxxxx';

// Bulk send the SMS
$notification = $twilio->notify->v1->services($notifySid)
    ->notifications->create([
        "toBinding" => $recipients,
        "body" => $body
    ]);