iclimber / laravel-zoom
Laravel Zoom package
Requires
- php: ^7.2
- firebase/php-jwt: ^5.0
- guzzlehttp/guzzle: ~6.0|~5.0|~4.0
- illuminate/support: ^5.2|^6.0|^7.0
Requires (Dev)
- orchestra/testbench: ^4.0
- phpunit/phpunit: ^8.0
README
Package to manage the Zoom API in Laravel
Installation
You can install the package via composer:
composer require iclimber/laravel-zoom
The service provider should automatically register for For Laravel > 5.4.
For Laravel < 5.5, open config/app.php and, within the providers array, append:
IClimber\Zoom\Providers\ZoomServiceProvider::class
Configuration file
Publish the configuration file
php artisan vendor:publish --provider="IClimber\Zoom\Providers\ZoomServiceProvider"
This will create a zoom/config.php within your config directory, where you add value for api_key and api_secret.
Usage
Everything has been setup to be similar to Laravel syntax.
Unfortunately the Zoom API is not very uniform and is a bit all over the place, so at the minute there are a number of hacks to be able to get this to work. We will refactor and improve this.
We use relationships so you will need to check the Zoom API, for example to get a list of meetings or webinars you need to pass in a user id. WE use a little bit of relationship magic to acheive this in a more laravel type way.
If you want to work with JWT App
$zoom = new \IClimber\Zoom\Zoom();
If you want to work with OAuth App
//user bearer token $zoom = new \IClimber\Zoom\Zoom('eyJhbGc...');
So to get a user info
$userBearerToken = 'eyJhbGc...'; $zoom = new \IClimber\Zoom\Zoom($userBearerToken); //for Account Level App or JWT $user = $zoom->user->find('test@domain.com'); //or $user = $zoom->user->first(); //for User Managed App $user = $zoom->user->me();
To get a list of meetings
$zoom = new \IClimber\Zoom\Zoom(); //for Account Level App or JWT $meetings = $zoom->user->find('test@domain.com')->meetings()->all(); //for User Managed App use method "user->me()" $meetings = $zoom->user->me()->meetings()->all();
Get user access token
//Get access and refresh token by user authorization code $userAccessData = Zoom::getUserAccessData('obBEe8ewaL_KdYKjnimT4KPd8KKdQt9FQ', 'my redirect url'); //Refresh token $userAccessData = Zoom::refreshToken('eyJhbGc...'); //Revoke token Zoom::revokeToken('eyJhbGc...');
Find all
The find all function returns a Laravel Collection so you can use all the Laravel Collection magic
$zoom = new \IClimber\Zoom\Zoom(); $users = $zoom->user->all();
Filtered
There are very few ocassions in the API where you can filter the results, but where you can you can use the where function. Again check the API documentation for where you can add a query to the request. To action you would do like so
$zoom = new \IClimber\Zoom\Zoom(); $thing = $zoom->thing->where('Name', '=', 'Test Name')->get();
You can also just passs the name and value if it is to equal
$zoom = new \IClimber\Zoom\Zoom(); $thing = $zoom->thing->where('Name', 'Test Name')->get();
To only get a single item use the 'first' method
$zoom = new \IClimber\Zoom\Zoom(); $thing = $zoom->thing->where('Name', 'Test Name')->first();
Find by ID
Just like Laravel we can use the 'find' method to return a single matched result on the ID. For users/registrants/panelists you can also use the email as well as the ID.
$zoom = new \IClimber\Zoom\Zoom(); $meeting = $zoom->meeting->find('000000000');
Creating Items
We can create and update records using the save function, below is the full save script for a creation.
$user = $zoom->user->create([ 'name' => 'Test Name', 'first_name' => 'First Name', 'last_name' => 'Last Name', 'email' => 'test@test.com', 'password' => 'secret', 'type' => 1 ]); $meeting = $user->meetings()->create([ 'type' => '2', 'start_time' => '2019-06-29T20:00:00Z', 'password' => '12345', 'settings' => [ 'join_before_host' => true ] ]); $meeting->topic = 'Meeting name'; $meetings->password = '12345'; $meetings->save(); $registrant = $meeting->registrants()->create([ 'email' => 'registratn@domain.com', 'first_name' => 'Test', 'last_name' => 'Registrant' ]);
There are also helper functions for adding sub objects
$meeting = $zoom->meeting->find('000000000'); $recurrence = $zoom->recurrence->create(['fields' => 'values']); $meeting->addRecurrence($recurrence); $meeting->save();
RESOURCES
We cover the main resources
Meetings
Panelists
Registrants
Users
Webinars
But some also have sub cresources, like
Recurrence
Occurrence
Settings (for meetings and webinars)
Tracking Fields
We aim to add additional resources/sub-resources over time
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email colin@macsi.co.uk instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.