PHP code example of puzzle9 / laravel-tencent-cloud-sdk

1. Go to this page and download the library: Download puzzle9/laravel-tencent-cloud-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

puzzle9 / laravel-tencent-cloud-sdk example snippets


use Puzzle9\TencentCloudSdk\TencentCloudSdk;

// 具体使用方式详见相关服务使用文档

    'drivers' => [
    	'live' => \TencentCloud\Live\V20180801\LiveClient::class,
    	// ...
    ],

$live = TencentCloudSdk::with('live');
//or
$live = TencentCloudSdk::createLiveDriver();

$live_help = TencentCloudSdk::with('liveHelp');
//or
$live_help = TencentCloudSdk::createLiveHelpDriver();

// 生成推流地址
$push_url = $live_help->getPushUrl('streamName');

// 生成包含防盗链推的流地址
$push_url = $live_help->getPushUrl('streamName', now()->addHour());

// 获得拉流地址
$push_url = $live_help->getPullUrl('streamName');

// 获得包含防盗链拉的流地址
$push_url = $live_help->getPullUrl('streamName', now()->addHour());

// 直播回调验证
$data = $live_help->notifyVerify();

// 直播回调相应
$live_help->notifySuccess();

    'drivers' => [
        'trtc' => \TencentCloud\Trtc\V20190722\TrtcClient::class,
    	// ...
    ],

$trtc = TencentCloudSdk::with('trtc');
//or
$trtc = TencentCloudSdk::createTrtcDriver();

$trtc_help = TencentCloudSdk::with('trtcHelp');
//or
$trtc_help = TencentCloudSdk::createTrtcHelpDriver();

// 获取 trtc sdk appid
$trtc_sdk_appid = $trtc_help->getSdkAppId();

// 获取 user sig
$sig = $trtc_help->userSig();
$user_sig = $sig->genUserSig('user_id');

    'drivers' => [
        'sms' => \TencentCloud\Sms\V20210111\SmsClient::class,
        // ...
    ],
    
     // 短信
    'sms'     => [
        'region'         => 'ap-beijing',
        'sms_sdk_app_id' => env('TENCENT_SMS_APP_ID'),
        'sign_name'      => env('TENCENT_SMS_SIGN_NAME'),
        'template_id'    => env('TENCENT_SMS_TEMPLATE_ID'),
    ],

$sms = TencentCloudSdk::with('sms');
//or
$sms = TencentCloudSdk::createSmsDriver();

$sms_help = TencentCloudSdk::with('smsHelp');
//or
$sms_help = TencentCloudSdk::createSmsHelpDriver();

// 发送短信
$sms_help->send('手机号', [
    '模板参数1',
])
shell
php artisan vendor:publish --tag=laravel-tencentsdk