1、微信开发最佳推荐【easywechat】
官网:https://www.easywechat.com/
安装:$ composer require w7corp/easywechat
使用:
use EasyWeChat\OfficialAccount\Application; $config = [ 'app_id' => 'wx3cf0f39249eb0exx', 'secret' => 'f1c242f4f28f735d4687abb469072axx', 'token' => 'easywechat', 'aes_key' => '' // 明文模式请勿填写 EncodingAESKey //... ]; $app = new Application($config);
2、阿里短信
官网:https://github.com/flc1125/dysms
安装:$ composer require flc/dysms
使用:
<?phpuse
Flc\Dysms\Client;
use Flc\Dysms\Request\SendSms;
$config = [
'accessKeyId'=>'LTAIbVA2LRQ1tULr',
'accessKeySecret' =>'ocS48RUuyBPpQHsfoWokCuz8ZQbGxl',
];
$client = new Client($config);
$sendSms = new SendSms;
$sendSms->setPhoneNumbers('1500000000');
$sendSms->setSignName('叶子坑');
$sendSms->setTemplateCode('SMS_77670013');
$sendSms->setTemplateParam(['code' => rand(100000, 999999)]);
$sendSms->setOutId('demo');
print_r($client->execute($sendSms));3、支付【微信、支付宝】
文档链接:https://www.kancloud.cn/langzi/zhifubao-weixin-wxchat-aliyun/1048249
安装:$ composer require zhaolicheng89/payment
使用:
SDK所需配置:
//微信支付SDK所需要的参数 $config= array( 'appid'=>'', // 填写高级调用功能的app id, 请在微信开发模式后台查询 'mchid'=>'', // 商户号 'key'=>'', // key 'notify_url'=>'', // 回调地址 'certPath'=>'', // 微信支付,证书cert的路径(可选,操作退款或打款时必需) 'keyPath'=>'', // 微信支付,证书key的路径(可选,操作退款或打款时必需) ); //支付宝支付(当面付)SDK所需要的参数 $config= array( 'app_id' =>'', // 应该id 'gatewayUrl'=>'', // 支付宝网关 'merchant_private_key'=> '', // 私钥 'alipay_public_key'=> '', // 公钥 'sign_type'=> '', //签名方式,默认为RSA2(RSA2048) 'charset'=> '', // 编码格式 'notify_url'=> '',//异步通知地址,只有扫码支付预下单可用 'MaxQueryRetry'=> '',//最大查询重试次数 'QueryDuration'=> '',//查询间隔 );
使用示例1:
//微信支付 $subject='测试001'; $outTradeNo='98562400002'; $totalAmount='0.01'; $Wechat=&\WxPayPubHelper\Wxpay($config); $type=1;//不传值的时候默认为1 支付业务类型 1订单支付 2 充值业务 用途:用于支付回调判断逻辑 $n=$Wechat->getPayQrcode($subject,$outTradeNo,$totalAmount,$type); print_r($n); //支付宝支付(当面付) $subject='测试001'; $outTradeNo='98562400002'; $totalAmount='0.01'; $type=1;//不传值的时候默认为1 支付业务类型 1订单支付 2 充值业务 用途:用于支付回调判断逻辑 $aliyun = &\Aliyun\dangmianfu\AlipayPrecreateCodeUrl($config); $t=$aliyun->aliyunPrecreateCodePay($subject,$outTradeNo,$totalAmount,$type); print_r($t);
使用示例2(需要独立加载Loader.php文件):
//支付宝支付(当面付)
require_once 'Aliyun/dangmianfu/Loader.php';
$subject='测试001';
$outTradeNo='98562400002';
$totalAmount='0.01';
$type=1;//不传值的时候默认为1 支付业务类型 1订单支付 2 充值业务 用途:用于支付回调判断逻辑
$aliyun = &\Aliyun\dangmianfu\Loader::get('dangmianfu',$config);
$t=$aliyun->aliyunPrecreateCodePay($subject,$outTradeNo,$totalAmount,$type);
print_r($t);
//微信支付
require_once 'WxPayPubHelper/Loader.php';
$Wechat=&\WxPayPubHelper\Loader::get('Wxpay',$wxconfig);
$type=1;//不传值的时候默认为1 支付业务类型 1订单支付 2 充值业务 用途:用于支付回调判断逻辑
$n=$Wechat->getPayQrcode($subject,$outTradeNo,$totalAmount,$type);
print_r($n);
...4、电子邮件创建和发送
文档链接:https://github.com/PHPMailer/PHPMailer
安装:$ composer require phpmailer/phpmailer
使用:
<?php
//将 PHPMailer 类导入全局命名空间
//这些必须在脚本的顶部,而不是在函数内部
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloaderrequire 'vendor/autoload.php';
//Create an instance; passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'smtp.example.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = 'user@example.com'; //SMTP username
$mail->Password = 'secret'; //SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
//Enable implicit TLS encryption
$mail->Port = 465;
//TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
//Recipients
$mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress('joe@example.net', 'Joe User'); //Add a recipient
$mail->addAddress('ellen@example.com'); //Name is optional
$mail->addReplyTo('info@example.com', 'Information'); $mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com'); //Attachments
$mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name
//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo '消息已发送';
} catch (Exception $e) {
echo "无法发送邮件。邮件程序错误: {$mail->ErrorInfo}";
}以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注【森林君博客】!
如果文章对你有帮助,你可以点击右边的 $ 打赏小编哟!
打赏小编
支付宝扫一扫
微信扫一扫