Commit d2e43e02 by zhaochengbin

小程序.云直播

1 parent 507e478b
<?php
/**
* 本模块所使用其它模块接口集合
*/
return [];
<?php
return [];
<?php
namespace Lestore\Minilive\Controllers;
use core\base\ControllerBase;
class BaseController extends ControllerBase {
public function onConstruct() {
$this->is_validation=false;
parent::onConstruct(); // TODO: Change the autogenerated stub
}
}
<?php
namespace Lestore\Minilive\Controllers;
use TencentCloud\Bizlive\V20190313\BizliveClient;
use TencentCloud\Bizlive\V20190313\Models\DescribeStreamPlayInfoListRequest;
use TencentCloud\Common\Credential;
use TencentCloud\Common\Exception\TencentCloudSDKException;
use TencentCloud\Common\Profile\ClientProfile;
use TencentCloud\Common\Profile\HttpProfile;
use TencentCloud\Cvm\V20170312\CvmClient;
use TencentCloud\Cvm\V20170312\Models\DescribeZonesRequest;
class DemoController extends BaseController {
public function onConstruct() {
parent::onConstruct(); // TODO: Change the autogenerated stub
}
public $domain='';
public $streamName='live';
public $key='';
public $exprie_time;
public function index(){
// try{
$cred=new Credential('AKID2yiCUi5WEgz2pNGCMbbcNxCNK2WsvTRE','mOkssNmywkKhqqy0qW2gHfGH6kBnDYi5');
$httpProfile = new HttpProfile();
$httpProfile->setEndpoint("bizlive.tencentcloudapi.com");
$clientProfile = new ClientProfile();
$clientProfile->setHttpProfile($httpProfile);
$client = new BizliveClient($cred, "ap-beijing", $clientProfile);
$req = new DescribeStreamPlayInfoListRequest();
$data=[
'EndTime'=>'2020-04-21 15:20:00',
'PlayDomain'=>'5000.playdomain.com',
'StartTime'=>'2020-04-21 15:08:00',
'StreamName'=>'stream1',
];
$params = json_encode($data,256);
$req->fromJsonString($params);
$resp = $client->DescribeStreamPlayInfoList($req);
print_r($resp);;
// }catch(TencentCloudSDKException $e){
// var_dump($e->getMessage());
// }
}
public function pushUrl(){
$pushUrl=$this->getPushUrl($this->domain,$this->streamName,$this->key,$this->exprie_time);
var_dump($pushUrl);
}
/**
* @param $domain
* @param $streamName
* @param null $key
* @param null $time
*
* @return string
*/
private function getPushUrl($domain, $streamName, $key = null, $time = null){
if($key && $time){
$txTime = strtoupper(base_convert(strtotime($time),10,16));
//txSecret = MD5( KEY + streamName + txTime )
$txSecret = md5($key.$streamName.$txTime);
$ext_str = "?".http_build_query(array(
"txSecret"=> $txSecret,
"txTime"=> $txTime
));
}
return "rtmp://".$domain."/live/".$streamName . (isset($ext_str) ? $ext_str : "");
}
}
<?php
namespace Lestore\minilive;
use Phalcon\Config;
use Phalcon\DiInterface;
use Phwoolcon\I18n;
use Phalcon\Loader;
use Phalcon\Mvc\ModuleDefinitionInterface;
class Module implements ModuleDefinitionInterface
{
/**
* 注册自动加载
* @param DiInterface $di
*/
public function registerAutoloaders(DiInterface $di = null)
{
$loader = new Loader();
$loader->registerNamespaces([
]);
$loader->register();
}
/**
* 服务注册
* @param DiInterface $di
*/
public function registerServices(DiInterface $di)
{
/**
* 加载当前模块配置文件
* 模块内使用方法:$this->config->名称
* 注意:该方式与系统本身配置获取方式不同,如需使用系统核心配置请使用Config::get()方式
*/
if (file_exists(__DIR__ . '/Config/config.php')) {
$di->set('config', function () use ($di) {
return new Config(include __DIR__ . '/Config/config.php');
});
}
/**
* 加载当前模块所使用API的配置文件
*/
if (file_exists(__DIR__ . '/Config/api.php')) {
$di->set('api', function () use ($di) {
return include __DIR__ . '/Config/api.php';
});
}
/**
* 国际化支持
* 使用__(名称)获取相应语言内容
* 注意:设置语言后首次加载不生效,再次刷新即可;如果模块内语言包名称与系统重复,则前者将会覆盖后者;许需使用系统语言包,请制定__()函数的第三个参数
*/
$locale = I18n::getCurrentLocale(); //获取当前所使用语言
if ($moduleLocaleFiles = glob(__DIR__ . '/Config/locale/' . $locale . '/*.php')) {
$i18n = new I18n(\Phwoolcon\Config::get('i18n'), ['locale' => $locale, 'force' => false, 'files' => $moduleLocaleFiles]); //合并模块内语言至系统预置语言中
//$i18n->loadLocale($locale);
}
/**
* 在这里可以注册很多个服务
* 下面的例子是一个URL生成的服务,在控制器调用:$this->di->get('buildUrl', ['index/index'])
*/
$di->set('buildUrl', function ($router) use ($di) {
//return $di->get('config')->url . '/' . $router;
return \Phwoolcon\Config::get('app.url') . '/' . $router;
});
}
}
Minilive
\ No newline at end of file
乐店云小程序云直播服务
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!