Rev 5837 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?phpdeclare(strict_types=1);namespace LeadersLinked\Controller;use \Firebase\JWT\JWT;use GuzzleHttp\Client;use Laminas\Db\Adapter\AdapterInterface;use LeadersLinked\Cache\CacheInterface;use Laminas\Mvc\Controller\AbstractActionController;use Laminas\Log\LoggerInterface;use Laminas\View\Model\JsonModel;use LeadersLinked\Library\Zoom;class ZoomController extends AbstractActionController{/**** @var AdapterInterface*/private $adapter;/**** @var CacheInterface*/private $cache;/**** @var LoggerInterface*/private $logger;/**** @var array*/private $config;/**** @param AdapterInterface $adapter* @param CacheInterface $cache* @param LoggerInterface $logger* @param array $config*/public function __construct($adapter, $cache , $logger, $config){$this->adapter = $adapter;$this->cache = $cache;$this->logger = $logger;$this->config = $config;}public function indexAction(){$data = ['success' => false,'data' => 'ERROR_METHOD_NOT_ALLOWED'];return new JsonModel($data);}public function addAction(){/*$currentUserPlugin = $this->plugin('currentUserPlugin');$currentUser = $currentUserPlugin->getUser();$request = $this->getRequest();// if($request->isPost()) {$base_url = $this->config['leaderslinked.zoom.base_url'];$token = $this->getAccessToken();$client = new Client(['base_uri' => $base_url,]);$response = $client->request('POST', '/v2/users/me/meetings', ['headers' => ['Authorization' => 'Bearer ' . $token],'json' => ['topic' => 'Let s Learn WordPress','agenda' => 'Description Let s Learn WordPress','type' => 2,'start_time' => '2023-01-30T20:30:00','duration' => '30', // 30 mins'password' => '123456','timezone' => 'America/Caracas','settings' => ['participant_video'=> 'true','auto_recording' => 'none',]],]);$data = json_decode($response->getBody()->getContents());echo '<pre>';print_r($data);echo '</pre>';exit;//echo "Join URL: ". $data->join_url;//echo "<br>";//echo "Meeting Password: ". $data->password;} else {$data = ['success' => false,'data' => 'ERROR_METHOD_NOT_ALLOWED'];return new JsonModel($data);}*/$token = 'EAAJaDxnm8uIBAGYjnYpOvjzm1BXbBgTtqfwn4YbagqIBGxfpWVZBObWtcnvfTJB6hMfHLWZBgG7dQ2O2UYMqZALYSLIQZC8swoNsHNYe3AMBkOjkt7YZBuIfXe22yyTgUZCBzGlsjbs0f72nNDvMlGNQlkCYNi3ZCDdXH61z9nW9xxUcdAnhk6M';$token = 'EAAJaDxnm8uIBAF3XfBml8yh9PqHOfO0UcwYALZAmoZCSPx6IkNZCRaVQaSWJfQALBqaRZCMziTddfvKgiVs1jwftg2sMyZBGixRTSDcXfvOv3nO4gZA2pCyruxa5iA1ZB01C83o2ZAg1Lnb07jeGF2C4d1Tauu3ZB9sZCJTkY4jMPt1Gnx8tpm5MAd';$client = new Client(['base_uri' => 'https://graph.facebook.com/v15.0',]);//$to = '584244343638';//$to = '59898137899';$to = '584122788242';$response = $client->request('POST', '/111473331819706/messages', ['headers' => ['Authorization' => 'Bearer ' . $token],'json' => ['messaging_product' => 'whatsapp','recipient_type' => 'individual','to' => $to,'type' => 'text','text' => ['preview_url' => false,'body' => 'MESSAGE_CONTENT']/*'type' => 'template','template' => ['name' => 'hello_world','language' => ['code' => 'en_US']] */],]);echo '<pre>';print_r($response->getBody()->getContents());echo '</pre>';exit;}public function listingAction(){$request = $this->getRequest();if($request->isGet()) {$zoom = new Zoom($this->adapter, $this->config, $this->cache);$response = $zoom->getOAuthAccessToken();if($response['success']) {$next_page_token = $this->params()->fromRoute('next_page');$access_token = $response['data'];$response = $zoom->getMeetings($access_token, $next_page_token) ;return new JsonModel($response);} else {return new JsonModel($response);}} else {$data = ['success' => false,'data' => 'ERROR_METHOD_NOT_ALLOWED'];}return new JsonModel($data);}public function deleteAction(){$request = $this->getRequest();//if($request->isPost()) {$meeting_id = $this->params()->fromRoute('id');$base_url = $this->config['leaderslinked.zoom.base_url'];$token = $this->getAccessToken();$client = new Client(['base_uri' => $base_url,]);$response = $client->request('DELETE', '/v2/meetings/' . $meeting_id, ['headers' => ['Authorization' => 'Bearer ' . $token]]);echo 'StatusCode : ' . $response->getStatusCode();exit;/*if (204 == $response->getStatusCode()) {$data = ['success' => true,'data' => 'Meeting deleted.'];} else {$data = ['success' => false,'data' => $response->getBody()->getContents()];}} else {$data = ['success' => false,'data' => 'ERROR_METHOD_NOT_ALLOWED'];}return new JsonModel($data);*/}public function participantsAction(){$request = $this->getRequest();// if($request->isGet()) {$meeting_id = $this->params()->fromRoute('id');$base_url = $this->config['leaderslinked.zoom.base_url'];$token = $this->getAccessToken();$client = new Client(['base_uri' => $base_url,]);$response = $client->request('GET', '/v2/past_meetings/' . $meeting_id , ['headers' => ['Authorization' => 'Bearer '. $token]]);print_r($response->getBody()->getContents());exit;/*$data = json_decode($response->getBody());if ( !empty($data) ) {foreach ( $data->participants as $p ) {$name = $p->name;$email = $p->user_email;echo "Name: $name";echo "Email: $email";}}} else {$data = ['success' => false,'data' => 'ERROR_METHOD_NOT_ALLOWED'];}return new JsonModel($data);*/}}