init
This commit is contained in:
3
app/Libraries/Zoom/.gitignore
vendored
Normal file
3
app/Libraries/Zoom/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/vendor
|
||||
.idea
|
||||
.idea/*
|
||||
146
app/Libraries/Zoom/Endpoint/Meetings.php
Normal file
146
app/Libraries/Zoom/Endpoint/Meetings.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright https://github.com/UsabilityDynamics/zoom-api-php-client/blob/master/LICENSE
|
||||
*/
|
||||
namespace Zoom\Endpoint;
|
||||
|
||||
use Zoom\Interfaces\Request;
|
||||
|
||||
/**
|
||||
* Class Meetings
|
||||
* @package Zoom\Endpoint
|
||||
*/
|
||||
class Meetings extends Request {
|
||||
|
||||
/**
|
||||
* Meetings constructor.
|
||||
* @param $apiKey
|
||||
* @param $apiSecret
|
||||
*/
|
||||
public function __construct($apiKey, $apiSecret) {
|
||||
parent::__construct($apiKey, $apiSecret);
|
||||
}
|
||||
|
||||
/**
|
||||
* List
|
||||
*
|
||||
* @param $userId
|
||||
* @param array $query
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function list(string $userId, array $query = []) {
|
||||
return $this->get("users/{$userId}/meetings", $query);
|
||||
}
|
||||
public function userInfo(string $email) {
|
||||
return $this->get("users/me");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create
|
||||
*
|
||||
* @param $userId
|
||||
* @param array $data
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function create(string $userId, array $data = null) {
|
||||
return $this->post("users/{$userId}/meetings", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Meeting
|
||||
*
|
||||
* @param $meetingId
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function meeting(string $meetingId) {
|
||||
return $this->get("meetings/{$meetingId}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove
|
||||
*
|
||||
* @param $meetingId
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function remove(string $meetingId) {
|
||||
return $this->delete("meetings/{$meetingId}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update
|
||||
*
|
||||
* @param $meetingId
|
||||
* @param array $data
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function update(string $meetingId, array $data = []) {
|
||||
return $this->patch("meetings/{$meetingId}", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Status
|
||||
*
|
||||
* @param $meetingId
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function status(string $meetingId, array $data = []) {
|
||||
return $this->put("meetings/{$meetingId}/status", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* List Registrants
|
||||
*
|
||||
* @param $meetingId
|
||||
* @param array $query
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function listRegistrants(string $meetingId, array $query = []) {
|
||||
return $this->get("meetings/{$meetingId}/registrants", $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Registrant
|
||||
*
|
||||
* @param $meetingId
|
||||
* @param array $data
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function addRegistrant(string $meetingId, $data = []) {
|
||||
return $this->post("meetings/{$meetingId}/registrants", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Registrant Status
|
||||
*
|
||||
* @param $meetingId
|
||||
* @param array $data
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function updateRegistrantStatus(string $meetingId, array $data = []) {
|
||||
return $this->put("meetings/{$meetingId}/registrants/status", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Past Meeting
|
||||
*
|
||||
* @param $meetingUUID
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function pastMeeting(string $meetingUUID) {
|
||||
return $this->get("past_meetings/{$meetingUUID}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Past Meeting Participants
|
||||
*
|
||||
* @param $meetingUUID
|
||||
* @param array $query
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function pastMeetingParticipants(string $meetingUUID, array $query = []) {
|
||||
return $this->get("past_meetings/{$meetingUUID}/participants", $query);
|
||||
}
|
||||
|
||||
}
|
||||
96
app/Libraries/Zoom/Endpoint/Recordings.php
Normal file
96
app/Libraries/Zoom/Endpoint/Recordings.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright https://github.com/UsabilityDynamics/zoom-api-php-client/blob/master/LICENSE
|
||||
*/
|
||||
namespace Zoom\Endpoint;
|
||||
|
||||
use Zoom\Interfaces\Request;
|
||||
|
||||
/**
|
||||
* Class Recordings
|
||||
* @package Zoom\Endpoint
|
||||
*/
|
||||
class Recordings extends Request {
|
||||
|
||||
/**
|
||||
* Recordings constructor.
|
||||
* @param $apiKey
|
||||
* @param $apiSecret
|
||||
*/
|
||||
public function __construct($apiKey, $apiSecret) {
|
||||
parent::__construct($apiKey, $apiSecret);
|
||||
}
|
||||
|
||||
/**
|
||||
* List
|
||||
*
|
||||
* @param $userId
|
||||
* @param array $query
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function listAll(string $userId, array $query = []) {
|
||||
return $this->get("users/{$userId}/recordings", $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Meeting
|
||||
*
|
||||
* @param $meetingId
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function meeting(string $meetingId) {
|
||||
return $this->get("meetings/{$meetingId}/recordings");
|
||||
}
|
||||
public function download(string $meetingId) {
|
||||
|
||||
return $this->get($meetingId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove All
|
||||
*
|
||||
* @param $meetingId
|
||||
* @param array $query
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function removeAll(string $meetingId, array $query = [ 'action' => 'trash' ]) {
|
||||
return $this->delete("meetings/{$meetingId}/recordings", $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove
|
||||
*
|
||||
* @param $meetingId
|
||||
* @param $recordingId
|
||||
* @param array $query
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function remove(string $meetingId, string $recordingId, array $query = [ 'action' => 'trash' ]) {
|
||||
return $this->delete("meetings/{$meetingId}/recordings/{$recordingId}", $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recover All
|
||||
*
|
||||
* @param $meetingId
|
||||
* @param array $data
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function recoverAll(string $meetingId, array $data = [ 'action' => 'recover' ]) {
|
||||
return $this->put("meetings/{$meetingId}/recordings/status", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recover
|
||||
*
|
||||
* @param $meetingId
|
||||
* @param $recordingId
|
||||
* @param array $data
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function recover(string $meetingId, string $recordingId, array $data = [ 'action' => 'recover' ]) {
|
||||
return $this->put("meetings/{$meetingId}/recordings/{$recordingId}/status", $data);
|
||||
}
|
||||
|
||||
}
|
||||
36
app/Libraries/Zoom/Endpoint/Reports.php
Normal file
36
app/Libraries/Zoom/Endpoint/Reports.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright https://github.com/UsabilityDynamics/zoom-api-php-client/blob/master/LICENSE
|
||||
*/
|
||||
namespace Zoom\Endpoint;
|
||||
|
||||
use Zoom\Interfaces\Request;
|
||||
|
||||
/**
|
||||
* Class Reports
|
||||
* @package Zoom\Interfaces
|
||||
*/
|
||||
class Reports extends Request {
|
||||
|
||||
/**
|
||||
* Meetings constructor.
|
||||
* @param $apiKey
|
||||
* @param $apiSecret
|
||||
*/
|
||||
public function __construct($apiKey, $apiSecret) {
|
||||
parent::__construct($apiKey, $apiSecret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Meeting Participants
|
||||
*
|
||||
* @param $meetingUUID
|
||||
* @param array $query
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function meetingParticipants(string $meetingUUID, array $query = []) {
|
||||
return $this->get("report/meetings/{$meetingUUID}/participants", $query);
|
||||
}
|
||||
|
||||
}
|
||||
76
app/Libraries/Zoom/Endpoint/Users.php
Normal file
76
app/Libraries/Zoom/Endpoint/Users.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright https://github.com/UsabilityDynamics/zoom-api-php-client/blob/master/LICENSE
|
||||
*/
|
||||
namespace Zoom\Endpoint;
|
||||
|
||||
use Zoom\Interfaces\Request;
|
||||
|
||||
/**
|
||||
* Class Users
|
||||
* @package Zoom\Interfaces
|
||||
*/
|
||||
class Users extends Request {
|
||||
|
||||
/**
|
||||
* Users constructor.
|
||||
* @param $apiKey
|
||||
* @param $apiSecret
|
||||
*/
|
||||
public function __construct($apiKey, $apiSecret) {
|
||||
parent::__construct($apiKey, $apiSecret);
|
||||
}
|
||||
|
||||
/**
|
||||
* List
|
||||
*
|
||||
* @param array $query
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function list( array $query = [] ) {
|
||||
return $this->get( "users", $query );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create
|
||||
*
|
||||
* @param array|null $data
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function create( array $data = null ) {
|
||||
return $this->post( "users", $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve
|
||||
*
|
||||
* @param $userID
|
||||
* @param array $query
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function retrieve( string $userID, array $query = [] ) {
|
||||
return $this->get( "users/{$userID}", $query );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove
|
||||
*
|
||||
* @param $userId
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function remove( string $userId ) {
|
||||
return $this->delete( "users/{$userId}" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update
|
||||
*
|
||||
* @param $userId
|
||||
* @param array $data
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function update( string $userId, array $data = [] ) {
|
||||
return $this->patch( "users/{$userId}", $data );
|
||||
}
|
||||
}
|
||||
143
app/Libraries/Zoom/Endpoint/Webinars.php
Normal file
143
app/Libraries/Zoom/Endpoint/Webinars.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright https://github.com/UsabilityDynamics/zoom-api-php-client/blob/master/LICENSE
|
||||
*/
|
||||
namespace Zoom\Endpoint;
|
||||
|
||||
use Zoom\Interfaces\Request;
|
||||
|
||||
/**
|
||||
* Class Webinars
|
||||
* @package Zoom\Endpoint
|
||||
*/
|
||||
class Webinars extends Request {
|
||||
|
||||
/**
|
||||
* webinars constructor.
|
||||
* @param $apiKey
|
||||
* @param $apiSecret
|
||||
*/
|
||||
public function __construct($apiKey, $apiSecret) {
|
||||
parent::__construct($apiKey, $apiSecret);
|
||||
}
|
||||
|
||||
/**
|
||||
* List
|
||||
*
|
||||
* @param $userId
|
||||
* @param array $query
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function list(string $userId, array $query = []) {
|
||||
return $this->get("users/{$userId}/webinars", $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create
|
||||
*
|
||||
* @param $userId
|
||||
* @param array $data
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function create(string $userId, array $data = null) {
|
||||
return $this->post("users/{$userId}/webinars", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Meeting
|
||||
*
|
||||
* @param $meetingId
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function meeting(string $meetingId) {
|
||||
return $this->get("webinars/{$meetingId}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove
|
||||
*
|
||||
* @param $meetingId
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function remove(string $meetingId) {
|
||||
return $this->delete("webinars/{$meetingId}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Update
|
||||
*
|
||||
* @param $meetingId
|
||||
* @param array $data
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function update(string $meetingId, array $data = []) {
|
||||
return $this->patch("webinars/{$meetingId}", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Status
|
||||
*
|
||||
* @param $meetingId
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function status(string $meetingId, array $data = []) {
|
||||
return $this->put("webinars/{$meetingId}/status", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* List Registrants
|
||||
*
|
||||
* @param $meetingId
|
||||
* @param array $query
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function listRegistrants(string $meetingId, array $query = []) {
|
||||
return $this->get("webinars/{$meetingId}/registrants", $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Registrant
|
||||
*
|
||||
* @param $meetingId
|
||||
* @param array $data
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function addRegistrant(string $meetingId, $data = []) {
|
||||
return $this->post("webinars/{$meetingId}/registrants", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Registrant Status
|
||||
*
|
||||
* @param $meetingId
|
||||
* @param array $data
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function updateRegistrantStatus(string $meetingId, array $data = []) {
|
||||
return $this->put("webinars/{$meetingId}/registrants/status", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Past Meeting
|
||||
*
|
||||
* @param $meetingUUID
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function pastMeeting(string $meetingUUID) {
|
||||
return $this->get("past_webinars/{$meetingUUID}");
|
||||
}
|
||||
|
||||
/**
|
||||
* Past Meeting Participants
|
||||
*
|
||||
* @param $meetingUUID
|
||||
* @param array $query
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function pastMeetingParticipants(string $meetingUUID, array $query = []) {
|
||||
return $this->get("past_webinars/{$meetingUUID}/participants", $query);
|
||||
}
|
||||
|
||||
}
|
||||
199
app/Libraries/Zoom/Interfaces/Request.php
Normal file
199
app/Libraries/Zoom/Interfaces/Request.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright https://github.com/UsabilityDynamics/zoom-api-php-client/blob/master/LICENSE
|
||||
*/
|
||||
namespace Zoom\Interfaces;
|
||||
|
||||
use Firebase\JWT\JWT;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
|
||||
class Request {
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $apiKey;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $apiSecret;
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $apiPoint = 'https://api.zoom.us/v2/';
|
||||
|
||||
/**
|
||||
* Request constructor.
|
||||
* @param $apiKey
|
||||
* @param $apiSecret
|
||||
*/
|
||||
public function __construct( $apiKey, $apiSecret ) {
|
||||
$this->apiKey = $apiKey;
|
||||
|
||||
$this->apiSecret = $apiSecret;
|
||||
|
||||
$this->client = new Client();
|
||||
}
|
||||
|
||||
/**
|
||||
* Headers
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function headers(): array {
|
||||
return [
|
||||
'Authorization' => 'Bearer ' . $this->generateJWT(),
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate J W T
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function generateJWT() {
|
||||
$token = [
|
||||
'iss' => $this->apiKey,
|
||||
'exp' => time() + 60,
|
||||
];
|
||||
|
||||
return JWT::encode($token, $this->apiSecret,'HS256');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get
|
||||
*
|
||||
* @param $method
|
||||
* @param array $fields
|
||||
* @return array|mixed
|
||||
*/
|
||||
protected function get($method, $fields = []) {
|
||||
try {
|
||||
$response = $this->client->request('GET', $this->apiPoint . $method, [
|
||||
'query' => $fields,
|
||||
'headers' => $this->headers(),
|
||||
]);
|
||||
|
||||
return $this->result($response);
|
||||
|
||||
} catch (ClientException $e) {
|
||||
|
||||
return (array)json_decode($e->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Post
|
||||
*
|
||||
* @param $method
|
||||
* @param $fields
|
||||
* @return array|mixed
|
||||
*/
|
||||
protected function post($method, $fields) {
|
||||
$body = \json_encode($fields, JSON_PRETTY_PRINT);
|
||||
|
||||
try {
|
||||
$response = $this->client->request('POST', $this->apiPoint . $method,
|
||||
['body' => $body, 'headers' => $this->headers()]);
|
||||
|
||||
return $this->result($response);
|
||||
|
||||
} catch (ClientException $e) {
|
||||
|
||||
return (array)json_decode($e->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Patch
|
||||
*
|
||||
* @param $method
|
||||
* @param $fields
|
||||
* @return array|mixed
|
||||
*/
|
||||
protected function patch($method, $fields) {
|
||||
$body = \json_encode($fields, JSON_PRETTY_PRINT);
|
||||
|
||||
try {
|
||||
$response = $this->client->request('PATCH', $this->apiPoint . $method,
|
||||
['body' => $body, 'headers' => $this->headers()]);
|
||||
|
||||
return $this->result($response);
|
||||
|
||||
} catch (ClientException $e) {
|
||||
|
||||
return (array)json_decode($e->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put
|
||||
*
|
||||
* @param $method
|
||||
* @param $fields
|
||||
* @return array|mixed
|
||||
*/
|
||||
protected function put($method, $fields) {
|
||||
$body = \json_encode($fields, JSON_PRETTY_PRINT);
|
||||
|
||||
try {
|
||||
$response = $this->client->request('PUT', $this->apiPoint . $method,
|
||||
['body' => $body, 'headers' => $this->headers()]);
|
||||
|
||||
return $this->result($response);
|
||||
|
||||
} catch (ClientException $e) {
|
||||
|
||||
return (array)json_decode($e->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* @param $method
|
||||
* @param $fields
|
||||
* @return array|mixed
|
||||
*/
|
||||
protected function delete($method, $fields = []) {
|
||||
$body = \json_encode($fields, JSON_PRETTY_PRINT);
|
||||
|
||||
try {
|
||||
$response = $this->client->request('DELETE', $this->apiPoint . $method,
|
||||
['body' => $body, 'headers' => $this->headers()]);
|
||||
|
||||
return $this->result($response);
|
||||
|
||||
} catch (ClientException $e) {
|
||||
|
||||
return (array)json_decode($e->getResponse()->getBody()->getContents());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Result
|
||||
*
|
||||
* @param Response $response
|
||||
* @return mixed
|
||||
*/
|
||||
protected function result(Response $response) {
|
||||
$result = json_decode((string)$response->getBody(), true);
|
||||
|
||||
$result['code'] = $response->getStatusCode();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
21
app/Libraries/Zoom/LICENSE
Normal file
21
app/Libraries/Zoom/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Zoom Video Communications
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
7
app/Libraries/Zoom/README.md
Normal file
7
app/Libraries/Zoom/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# PHP
|
||||
|
||||
Zoom REST API's using PHP
|
||||
Visit https://zoom.us/developer for more details
|
||||
|
||||
## Support
|
||||
For any questions or issues, please visit our new Community Support Forum at https://devforum.zoom.us/
|
||||
119
app/Libraries/Zoom/ZoomAPI.php
Normal file
119
app/Libraries/Zoom/ZoomAPI.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace Zoom;
|
||||
|
||||
use Zoom\Endpoint\Users;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
class ZoomAPI
|
||||
{
|
||||
|
||||
/**
|
||||
* @var null
|
||||
*/
|
||||
private $apiKey = null;
|
||||
|
||||
/**
|
||||
* @var null
|
||||
*/
|
||||
private $apiSecret = null;
|
||||
|
||||
/**
|
||||
* @var null
|
||||
*/
|
||||
private $users = null;
|
||||
|
||||
protected string $accessToken;
|
||||
protected $client;
|
||||
/**
|
||||
* Retorna uma instância única de uma classe.
|
||||
*
|
||||
* @staticvar Singleton $instance A instância única dessa classe.
|
||||
*
|
||||
* @return Singleton A Instância única.
|
||||
*/
|
||||
public function getInstance()
|
||||
{
|
||||
static $users = null;
|
||||
if (null === $users) {
|
||||
$this->users = new Users($this->apiKey, $this->apiSecret);
|
||||
}
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zoom constructor.
|
||||
* @param $apiKey
|
||||
* @param $apiSecret
|
||||
*/
|
||||
public function __construct($apiKey, $apiSecret, $account_id)
|
||||
{
|
||||
|
||||
$this->apiKey = $apiKey;
|
||||
|
||||
$this->apiSecret = $apiSecret;
|
||||
|
||||
$client = new Client([
|
||||
'headers' => [
|
||||
'Authorization' => 'Basic ' . base64_encode($this->apiKey . ':' . $this->apiSecret),
|
||||
'Host' => 'zoom.us',
|
||||
],
|
||||
]);
|
||||
$response = $client->request('POST', "https://zoom.us/oauth/token", [
|
||||
'form_params' => [
|
||||
'grant_type' => 'account_credentials',
|
||||
'account_id' => $account_id,
|
||||
],
|
||||
]);
|
||||
$responseBody = json_decode($response->getBody(), true);
|
||||
// print_r($responseBody);
|
||||
// die;
|
||||
$this->accessToken = $responseBody['access_token'];
|
||||
// return $responseBody['access_token'];
|
||||
}
|
||||
public function createMeeting($data)
|
||||
{
|
||||
$now = date("Y-m-d\TH:i", strtotime(date('Y-m-d H:i:s', time())));
|
||||
$postFields = [
|
||||
'topic' => $data['title'],
|
||||
'type' => 2, // Scheduled meeting
|
||||
'start_time' => $now, // Meeting start time in ISO 8601 format
|
||||
'duration' => 60 * 12, // Meeting duration in minutes
|
||||
'timezone' => 'UTC+07',
|
||||
'agenda' => $data['description']
|
||||
];
|
||||
$this->client = new Client([
|
||||
'base_uri' => 'https://api.zoom.us/v2/',
|
||||
'headers' => [
|
||||
'Authorization' => 'Bearer ' . $this->accessToken,
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
]);
|
||||
try {
|
||||
$response = $this->client->request('POST', 'users/me/meetings', [
|
||||
'json' => $postFields,
|
||||
]);
|
||||
$res = json_decode($response->getBody(), true);
|
||||
return [
|
||||
'status' => true,
|
||||
'data' => $res,
|
||||
];
|
||||
} catch (\Throwable $th) {
|
||||
return [
|
||||
'status' => false,
|
||||
'message' => $th->getMessage(),
|
||||
];
|
||||
}
|
||||
}
|
||||
/*Functions for management of users*/
|
||||
|
||||
// public function createUser()
|
||||
// {
|
||||
// $createAUserArray['action'] = 'create';
|
||||
// $createAUserArray['email'] = $_POST['email'];
|
||||
// $createAUserArray['user_info'] = $_POST['user_info'];
|
||||
|
||||
// return $this->users->create($createAUserArray);
|
||||
// }
|
||||
}
|
||||
13
app/Libraries/Zoom/composer.json
Normal file
13
app/Libraries/Zoom/composer.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "zoom/zoom",
|
||||
"description": "Api Zoom",
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true,
|
||||
"require": {
|
||||
"guzzlehttp/guzzle": "^7.8",
|
||||
"firebase/php-jwt": "^6.9"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {"Zoom\\": ""}
|
||||
}
|
||||
}
|
||||
8
app/Libraries/Zoom/index.php
Normal file
8
app/Libraries/Zoom/index.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$zoom = new \Zoom\ZoomAPI('AAAAA', 'BBBBB');
|
||||
|
||||
|
||||
var_dump($zoom->createUser() );
|
||||
exit();
|
||||
Reference in New Issue
Block a user