Rev 1 | 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 Laminas\Mvc\Controller\AbstractActionController;use Laminas\Log\LoggerInterface;use Laminas\View\Model\JsonModel;use LeadersLinked\Library\Zoom;class ZoomController extends AbstractActionController{/**** @var \Laminas\Db\Adapter\AdapterInterface*/private $adapter;/**** @var \LeadersLinked\Cache\CacheInterface*/private $cache;/**** @var \Laminas\Log\LoggerInterface*/private $logger;/**** @var array*/private $config;/**** @var \Laminas\Mvc\I18n\Translator*/private $translator;/**** @param \Laminas\Db\Adapter\AdapterInterface $adapter* @param \LeadersLinked\Cache\CacheInterface $cache* @param \Laminas\Log\LoggerInterface LoggerInterface $logger* @param array $config* @param \Laminas\Mvc\I18n\Translator $translator*/public function __construct($adapter, $cache, $logger, $config, $translator){$this->adapter = $adapter;$this->cache = $cache;$this->logger = $logger;$this->config = $config;$this->translator = $translator;}public function indexAction(){$data = ['success' => false,'data' => 'ERROR_METHOD_NOT_ALLOWED'];return new JsonModel($data);}public function addAction(){$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']] */],]);}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]]);}}