MacsiDigital / laravel-zoom

Laravel Zoom Package
MIT License
261 stars 135 forks source link

Not able to create meeting with template id #128

Open philharmonie opened 1 year ago

philharmonie commented 1 year ago

I am trying to create a meeting from a template id:

class ZoomService
{
    const TYPE_SCHEDULED = 2;
    const TYPE_RECURRING = 8;
    const WEEKENDSEMINAR = "Weekend Seminar";
    const REGULARSEMINAR = "Regular Seminar";

    public static function createMeeting(Carbon $start, Carbon $end, string $type)
    {
        $user = Zoom::user()->find('me');

        // Get template id
        $templates = collect($user->handleResponse($user->sendRequest('get', ['users/' . $user->id . '/meeting_templates']))->templates);
        $template_id = $templates->filter(function ($template) use ($type) {
            return $template['name'] == $type;
        })->first()['id'] ?? null;

        if (is_null($template_id)) {
            Log::error("Template {$type} not found");
            throw new \Exception('Template not found');
        }

        $recurring = match ($type) {
            self::WEEKENDSEMINAR => true,
            self::REGULARSEMINAR => false,
            default => false
        };

        return Zoom::user()->find('me')->meetings()->create([
            'type' => $recurring ? self::TYPE_RECURRING : self::TYPE_SCHEDULED,
            'password' => (string) rand(100000, 999999),
            'timezone' => config('app.timezone'),
            'duration' => $start->diffInMinutes($end),
            'start_time' => $start->format('Y-m-d\TH:i:s'),
            'template_id' => $template_id,
            'recurrence' => [
                'end_date_time' => $end->format('Y-m-d\TH:i:s'),
                'end_times' => $recurring ? $start->diffInDays($end) + 1 : 1,
                'type' => 1
            ]
        ]);
    }
}

The template id exists and is the same like the ID in the URL when I open the template from the Zoom web UI. None of the template settings are used for the created meeting and the meeting topic is the default topic. The weirdest observation is, that when I dd() the created meeting, I see in the attributes, that the template_id is set correctly:

array:21 [▼
    "type" => 2
    "password" => "309551"
    "timezone" => "Europe/Berlin"
    "duration" => 1860
    "start_time" => "2023-03-01T09:00:00Z"
    "template_id" => "AxH9m6YgSfqL8SrpXVWweg" <-- this is the correct id
    "user_id" => "Wh2bmT_bQfyxK3qKoeW9jw"
    "uuid" => "IglPzGivRuCaZymPXaQ6jg=="
    "id" => 75228235554
    "host_id" => "Wh2bmT_bQfyxK3qKoeW8jk"
    "host_email" => "host@mail.de"
    "topic" => "Zoom Meeting"
    "status" => "waiting"
    "created_at" => "2023-02-27T09:26:29Z"
    "start_url" => "https://us06web.zoom.us/s/...▶"
    "join_url" => "https://us06web.zoom.us/j/..."
    "h323_password" => "309551"
    "pstn_password" => "309551"
    "encrypted_password" => "bStId1NDODhQVFhOSllQWENUOHptZz08"
    "settings" => array:36 [▶]
    "pre_schedule" => false
  ]
mjzavar commented 1 year ago

same problem here