Hey there, fellow developer! Ready to supercharge your PHP application with Zoom's powerful API? You're in the right place. We're going to walk through building a Zoom API integration using the awesome portaldna/zoomapi
package. Buckle up, because by the end of this guide, you'll be creating meetings, managing participants, and handling webhooks like a pro.
Before we dive in, make sure you've got:
Got all that? Great! Let's get started.
First things first, let's get that portaldna/zoomapi
package installed. Fire up your terminal and run:
composer require portaldna/zoomapi
Easy peasy, right?
Now, let's set up those API credentials and get our Zoom client ready to roll.
use Zoom\Zoom; $zoom = new Zoom([ 'apiKey' => 'YOUR_API_KEY', 'apiSecret' => 'YOUR_API_SECRET' ]);
Replace YOUR_API_KEY
and YOUR_API_SECRET
with your actual Zoom API credentials. Keep these safe and out of version control!
Let's start with something simple - getting user info:
$user = $zoom->users->get('me'); echo "Hello, " . $user->first_name . "!";
Now for the fun part - creating a meeting:
$meeting = $zoom->meetings->create('me', [ 'topic' => 'My Awesome Meeting', 'type' => 2, // Scheduled meeting 'start_time' => '2023-06-01T10:00:00Z', 'duration' => 60, // 60 minutes ]); echo "Meeting created with ID: " . $meeting->id;
Want to see all your meetings? No problem:
$meetings = $zoom->meetings->list('me'); foreach ($meetings as $meeting) { echo $meeting->topic . " - " . $meeting->start_time . "\n"; }
Let's add some participants to our meeting:
$zoom->meetings->addRegistrant($meetingId, [ 'email' => '[email protected]', 'first_name' => 'John', 'last_name' => 'Doe' ]);
Webhooks are a great way to get real-time updates. Here's a simple webhook handler:
$payload = json_decode(file_get_contents('php://input'), true); if ($payload['event'] === 'meeting.started') { // Do something when a meeting starts }
Always wrap your API calls in try-catch blocks:
try { $meeting = $zoom->meetings->create('me', [...]); } catch (\Exception $e) { echo "Oops! " . $e->getMessage(); }
And don't forget about rate limits. The package handles this for you, but it's good to be aware of it.
Unit testing is your friend. Here's a quick example using PHPUnit:
public function testCreateMeeting() { $zoom = new Zoom([...]); $meeting = $zoom->meetings->create('me', [...]); $this->assertNotNull($meeting->id); }
When deploying, remember:
And there you have it! You're now equipped to build some seriously cool Zoom integrations. Remember, the Zoom API is vast, so don't be afraid to explore and experiment. Happy coding!
For more info, check out the Zoom API docs and the portaldna/zoomapi GitHub repo.
Now go forth and create some amazing Zoom-powered applications!