定制 blastream/php-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

blastream/php-sdk

最新稳定版本:1.0.37

Composer 安装命令:

composer require blastream/php-sdk

包简介

consume blastream rest api with php sdk

README 文档

README

All URIs are relative to https://api.v2.blastream.com/api-docs

Install

composer require blastream/php-sdk

Examples

Create a channel and show iframe with administrator account

<?php
require './vendor/autoload.php';

use Blastream\Instance as Blastream;

$blastream = new Blastream(PUBLIC_KEY, PRIVATE_KEY); 
$blastream->setTimeout(6000);
try {
    $channel = $blastream->createOrGetChannel('my-channel');
    $iframe = $channel->getIframe(800, 600, [
        'username' => 'admin username'
    ]);
    echo $iframe;
}
catch (Exception $e) {
    echo 'Exception intercepted : ',  $e->getMessage(), "\n";
}
?>

Create a collaborator

<?php
require './vendor/autoload.php';

use Blastream\Instance as Blastream;

$blastream = new Blastream(PUBLIC_KEY, PRIVATE_KEY); 
try {
    $channel = $blastream->createOrGetChannel('my-channel');
    $colaborator = $channel->createOrGetCollaborator('alan', 'animator'); //The collaborator username is unique for a channel
    $iframe = $colaborator->getIframe(800, 600);
    echo $iframe;
}
catch (Exception $e) {
    echo 'Exception intercepted : ',  $e->getMessage(), "\n";
}
?>    

Create a participant

<?php
require './vendor/autoload.php';

use Blastream\Instance as Blastream;

$blastream = new Blastream(PUBLIC_KEY, PRIVATE_KEY); 
try {
    $channel = $blastream->createOrGetParticipant('my-channel', 'my-part');
    $iframe = $channel->getIframe(800, 600);
    echo $iframe;
}
catch (Exception $e) {
    echo 'Exception intercepted : ',  $e->getMessage(), "\n";
}
?>    

Get replays of a channel

<?php
require './vendor/autoload.php';

use Blastream\Instance as Blastream;

$blastream = new Blastream(PUBLIC_KEY, PRIVATE_KEY); 
try {
    $channel = $blastream->createOrGetChannel('my-channel');
    $list = $channel->getReplays();
    print_r($list);
}
catch (Exception $e) {
    echo 'Exception intercepted : ',  $e->getMessage(), "\n";
}
?>

Register a hook url to notified when a new replay is available

<?php
require './vendor/autoload.php';

use Blastream\Instance as Blastream;

$blastream = new Blastream(PUBLIC_KEY, PRIVATE_KEY); 
try {
    $blastream->registerHook('https://http.jay.invaders.stream/hook_from_blastream.php');
}
catch (Exception $e) {
    echo 'Exception intercepted : ',  $e->getMessage(), "\n";
}

?>    

Update plan of a channel

<?php
require './vendor/autoload.php';

use Blastream\Instance as Blastream;

$blastream = new Blastream(PUBLIC_KEY, PRIVATE_KEY); 
try {
    $channel = $blastream->createOrGetChannel('my-channel');
    $channel->updateSubscription('pro2', 'hourly');
}
catch (Exception $e) {
    echo 'Exception intercepted : ',  $e->getMessage(), "\n";
}
?>

Update access rule of a channel

<?php
require './vendor/autoload.php';

use Blastream\Instance as Blastream;

$blastream = new Blastream(PUBLIC_KEY, PRIVATE_KEY); 
try {
    $channel = $blastream->createOrGetChannel('my-channel');
    //can be PUBLIC or PRIVATE
    $channel->setAccessRule('PRIVATE', [
        'knock' => 1 //can be knock or password, if you set password you have to put the password value : password => 'my-password'
    ]);
}
catch (Exception $e) {
    echo 'Exception intercepted : ',  $e->getMessage(), "\n";
}
?>

Update settings of a channel

<?php
require './vendor/autoload.php';

use Blastream\Instance as Blastream;

$blastream = new Blastream(PUBLIC_KEY, PRIVATE_KEY); 
try {
    $channel = $blastream->createOrGetChannel('my-channel');
    $channel->updateSettings([
        'autojoin' => 1
    ]);
}
catch (Exception $e) {
    echo 'Exception intercepted : ',  $e->getMessage(), "\n";
}
?>

Update a collaborator

<?php
require './vendor/autoload.php';

use Blastream\Instance as Blastream;

$blastream = new Blastream(PUBLIC_KEY, PRIVATE_KEY); 
try {
    $channel = $blastream->createOrGetChannel('my-channel');
    $colaborator = $channel->createOrGetCollaborator('Collaborator Username', 'moderator'); 
    $colaborator->update('New username', 'animator');
}
catch (Exception $e) {
    echo 'Exception intercepted : ',  $e->getMessage(), "\n";
}
?>    

Update custom design of a channel

<?php
require './vendor/autoload.php';

use Blastream\Instance as Blastream;

$blastream = new Blastream(PUBLIC_KEY, PRIVATE_KEY); 
try {
  $channel = $blastream->createOrGetChannel('my-channel');
  $upload = $channel->uploadPic(IMAGE_FILE_ABSOLUTE_PATH);
  $channel->setCustom([
      "colors"=>  [
        "#ff0000",
        "#ff0000",
        "#ff0000",
        "#ff0000"
      ],
      "js" => "alert('ok')",
      "css" => "",
      "logo" => $upload['file']
  ]);
}
catch (Exception $e) {
    echo 'Exception intercepted : ',  $e->getMessage(), "\n";
}
?>

Update a scene

<?php
require './vendor/autoload.php';

use Blastream\Instance as Blastream;

$blastream = new Blastream(PUBLIC_KEY, PRIVATE_KEY); 
try {
    $channel = $blastream->createOrGetChannel('my-channel');
    $scenes = $channel->getScenes(); 
    
    //can be 'overlay', 'logo' or 'background'
    $upload = $channel->uploadScenePic('overlay', IMAGE_FILE_ABSOLUTE_PATH);
    foreach($scenes as $scene) {
        if($scene->isDefault()) {
            $scene->update([
                'overlay' => [
                    'src' => $upload['file'],
                    'play' => true
                ],
                'background' => [
                    'color' => '#ff0000'
                ]
            ]);
        }
    }
}
catch (Exception $e) {
    echo 'Exception intercepted : ',  $e->getMessage(), "\n";
}

?>    

统计信息

  • 总下载量: 20.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-07-05