Ejemplo n.º 1
0
 /**
  * create OrtcConfig from laravel config
  */
 protected function createOrtcConfig(array $config)
 {
     $ortcConfig = new OrtcConfig();
     $ortcConfig->setApplicationKey($config['credentials']['application_key']);
     $ortcConfig->setPrivateKey($config['credentials']['private_key']);
     $ortcConfig->setBalancerUrl($config['api']['balancer_url']);
     $ortcConfig->setAuthenticationPath($config['api']['authentication']['path']);
     $ortcConfig->setSendPath($config['api']['send_message']['path']);
     $ortcConfig->setMaxChunkSize($config['api']['send_message']['max_chunk_size']);
     $ortcConfig->setBatchPoolSize($config['api']['send_message']['batch_pool_size']);
     $ortcConfig->setPreMessageString($config['api']['send_message']['pre_message_string']);
     $ortcConfig->setVerifySsl($config['api']['verify_ssl']);
     $this->ortcConfig = $ortcConfig;
 }
Ejemplo n.º 2
0
<?php

use Nikapps\OrtcPhp\Configs\OrtcConfig;
use Nikapps\OrtcPhp\Models\Channel;
use Nikapps\OrtcPhp\Models\Requests\AuthRequest;
use Nikapps\OrtcPhp\Models\Requests\SendMessageRequest;
use Nikapps\OrtcPhp\Ortc;
require_once '../vendor/autoload.php';
$ortcConfig = new OrtcConfig();
$ortcConfig->setApplicationKey('YOUR_APPLICATION_KEY');
$ortcConfig->setPrivateKey('YOUR_PRIVATE_KEY');
$ortcConfig->setVerifySsl(false);
$authToken = 'YOUR_AUTHENTICATION_TOKEN';
$channels = [];
$testChannel = new Channel();
$testChannel->setName('CHANNEL_NAME');
$testChannel->setPermission(Channel::PERMISSION_WRITE);
$channels[] = $testChannel;
$ortc = new Ortc($ortcConfig);
if (isset($_POST['message'])) {
    $sendMessageRequest = new SendMessageRequest();
    $sendMessageRequest->setAuthToken($authToken);
    $sendMessageRequest->setChannelName($testChannel->getName());
    $sendMessageRequest->setMessage($_POST['message']);
    $ortc->sendMessage($sendMessageRequest);
} else {
    $authRequest = new AuthRequest();
    $authRequest->setAuthToken($authToken);
    $authRequest->setExpireTime(5 * 60);
    $authRequest->setPrivate(true);
    $authRequest->setChannels($channels);