dgwht/php-class

自己用的PHP库

v1.0.3 2020-12-20 13:39 UTC

This package is auto-updated.

Last update: 2024-10-20 22:58:08 UTC


README

介绍

1.邮件发送

2.短信发送(阿里/腾讯)

3.上传文件到对象存储(OSS/COS)

安装教程

composer require dgwht/php-class

使用说明

>邮件发送

use dgwht/email/Email;

$EMAIL = new Email([
    "host" => "smtp.exmail.qq.com",
    "port" => "25",
    "user" => "admin@dgwht.com",
    "pass" => "xxxxxxxxx",
    "email" => "admin@dgwht.com",
]);
$ret = $EMAIL->send('2393176043@qq.com','标题测试','内容测试');

if($ret){
    echo "成功:[{$EMAIL->Msg}]";
}else{
    echo "失败:[{$EMAIL->Msg}]";
}

短信发送

use dgwht/sms/Sms;

//腾讯
//$SMS = new Sms([
//    "appid" => "1400158411",
//    "appkey" => "50b54363ed4b23a9ea0d28xxxxxxxx",
//    "sign" => "泪心世界",
//    "tplid" => "348208",
//],'Tx');
//$ret = $SMS->send(18388888888,[rand(1111,6666),5]);

//阿里
$SMS = new Sms([
    "appid" => "LTAI4FdEgtrxxxxx",
    "appkey" => "gSziEzn4t7bJg1jIpFxxxxxxx",
    "sign" => "微后台",
    "tplid" => "SMS_85445047",
],'Ali');
$ret = $SMS->send(18388888888,["name" => "章继忠"]);

if($ret){
    echo "成功:[{$SMS->Msg}]";
}else{
    echo "失败:[{$SMS->Msg}]";
}

上传文件到对象存储

use dgwht/file/File;

//腾讯
//$FILE = new File([
//    "appid" => "AKIDzsbAXidT3iT6Ztl2oPVxxxxx",
//    "appkey" => "2s582nO1UYXMG6mK7qgcS8xxxxx",
//    "region" => "ap-chengdu",
//    "bucket" => "test-1252881831",
//],'Tx');

//阿里
$FILE = new File([
    "appid" => "LTAI4FdEgtr2kneRWgpSnzQB",
    "appkey" => "gSziEzn4t7bJg1jIpFGqeWYRdfwM55",
    "region" => "chengdu",
    "bucket" => "dgwht-test",
],'Ali');

//上传
$ret = $FILE->up("dd/1.php","index.php",[
    "Content-Disposition" => "attachment;filename=666.php"//阿里
    //"ContentDisposition" => "attachment;filename=666.php"//腾讯
]);
if($ret){
    echo "成功:[{$FILE->Msg}]";
}else{
    echo "失败:[{$FILE->Msg}]";
}

//获取签名后的下载地址
$url = $FILE->getSignUrl(15,"dd/1.php");
echo "<a href='{$url}'>{$url}</a>";
//header("Location: {$url}"); exit();

//删除
$ret = $FILE->del(["dd/1.php","dd/2.php","dd/3.php"]);
if($ret){
    echo "成功";
}else{
    echo "失败";
}