'振',
'lastname' => '李',
'email' => '1129121659@qq.com',
'name_en' => '蹦极',
];
$slot = [
'starttime' => time(),
];
$message =
'Hi,'.$order['firstname']. ' ' .$order['lastname'].'!
We are looking forward to seeing you at the following class tomorrow!
Class:'.$order['name_en'].'
Date: '.date('d F Y',$slot['starttime']).'
Time: '.date('H:i a',$slot['starttime']).'
Please arrive 10 minutes before the class timing to prepare for the harness fitting!
We are located at 450 Alexandra Road, #02-01,
Singapore 119960. For those who are driving, parking is available on level 2 of the building. For those who are taking public transport, the nearest mrt is Labrador Park MRT (7-10 minutes walk) and there is also a bus stop available just outside the building!
We look forward to seeing you for an amazing session! ❤
Best Regards,
Elin Dance Studio
';
$obj = new Email();
$result = $obj
->to($order['email'])
->subject('You have a class tomorrow!')
->message($message)
->send();
dump($result);
}
public function hitpay_redirect_log(){
$url = input('url','');
$data = [
'url' => $url,
'createdate' => date('Y-m-d H:i:s'),
];
Db::name('hitpay_redirect_log')->insertGetId($data);
$this->success(1);
}
public function getui2(){
$config = config('getui');
$this->appId = $config['gt_app_id'];
$this->appKey = $config['gt_app_key'];
$this->appSecret = $config['gt_app_secret'];
$this->masterSecret = $config['gt_master_secret'];
//创建API,APPID等配置参考 环境要求 进行获取
$api = new GTClient("https://restapi.getui.com",$config['gt_app_key'], $config['gt_app_id'],$config['gt_master_secret']);
//设置推送参数
$push = new GTPushRequest();
$push->setRequestId("请求唯一标识号");
$message = new GTPushMessage();
$notify = new GTNotification();
$notify->setTitle("设置通知标题");
$notify->setBody("设置通知内容");
//点击通知后续动作,目前支持以下后续动作:
//1、intent:打开应用内特定页面url:打开网页地址。2、payload:自定义消息内容启动应用。3、payload_custom:自定义消息内容不启动应用。4、startapp:打开应用首页。5、none:纯通知,无后续动作
$notify->setClickType("none");
$message->setNotification($notify);
$push->setPushMessage($message);
$push->setCid("CID");
//处理返回结果
$result = $api->pushApi()->pushToSingleByCid($push);
}
public function getui(){
$getui = new Getui();
$cid = 1;
$title = '标题';
$body = '内容';
$ring_name = 'ringname';
$type = 1;
$platform = 'android';
$getui->push($cid, $title, $body, $ring_name, $type, $platform);
}
public function sendtoall(){
$getui = new Getui();
$title = '我是群发标题11222';
$body = '接下来两周的课程将于今天下午 6.45 发布22333';
$rs = $getui->sendtoall($title, $body, 1, 'android');
$rs = $getui->sendtoall($title, $body, 1, 'ios');
}
public function test2(){
$a = time();
$b = $this->date_lang($a);
dump($b);
$b = $this->weekdatetime_lang($a);
dump($b);
}
public function testweek(){
$a = '1704609069';
$b = date('w',$a);
dump($b);
$b = date('N',$a);
dump($b);
}
public function test1(){
$SnSclient = new SnsClient([
'profile' => 'default',
'region' => 'us-east-1',
'version' => '2010-03-31'
]);
$subscription_token = 'arn:aws:sns:us-east-1:111122223333:MyTopic:123456-abcd-12ab-1234-12ba3dc1234a';
$topic = 'arn:aws:sns:us-east-1:111122223333:MyTopic';
try {
$result = $SnSclient->confirmSubscription([
'Token' => $subscription_token,
'TopicArn' => $topic,
]);
var_dump($result);
} catch (AwsException $e) {
// output error message if fails
error_log($e->getMessage());
}
}
public function test(){
$out_trade_no = createUniqueNo('Test');
$money = '1';
$notifyurl = config('notify_cdnurl');
$rs = $this->hitpay_payment($out_trade_no,$money,$notifyurl);
dump($rs);
//payorder 保存 $rs['id'] 为 payment_request_id
}
public function hitpay_getstatus(){
$payment_request_id = '9d0f79b7-68b1-4065-b5e5-75e8cd6a3a4c';
$apiKey = config('hitpay.apikey');
$hitPayClient = new \HitPay\Client($apiKey, true);
$data = $hitPayClient->getPaymentStatus($payment_request_id);
dump($data);
dump($data->status);
}
public function hitpay_payment($out_trade_no,$money,$notifyurl)
{
$return = [
'status' => false,
'msg' => '',
'url' => '',
'id' => 0,
];
$apiKey = config('hitpay.apikey');
try {
$hitPayClient = new \HitPay\Client($apiKey, true);
$request = new \HitPay\Request\CreatePayment();
$request->setAmount($money)
->setCurrency('SGD')
->setPaymentMethods(['paynow_online','card'])
->setPurpose('Elin Dance Studio')
->setWebhook($notifyurl)
->setReferenceNumber($out_trade_no);
$result = $hitPayClient->createPayment($request);
$return['status'] = true;
$return['url'] = $result->getUrl();
$return['id'] = $result->getId();
//print_r($result);
/*$data = $hitPayClient->getPaymentStatus($result->getId());
dump($data);
dump($data->status);*/
/*$data = $hitPayClient->deletePaymentRequest($data->getId());
print_r($data);*/
} catch (\Exception $e) {
$return['msg'] = $e->getMessage();
}
return $return;
}
public function qixunyun_sms($mobile,$code){
//配置
$config = config('qixunyun_sms');
$name = $config['name'];
$password = $config['password'];
$signname = $config['signname'];
$url = 'https://api.hnsls5g.com/eums/sms/utf8/send.do';
$seed = date('YmdHis');
$content = '【'.$signname.'】Your verification Code is : ' . $code;
$data = [
'name' => $name,
'seed' => $seed,
'key' => strtolower(md5(strtolower(md5($password)).$seed)),
'dest' => $mobile,
'content' => $content,
];
$params = http_build_query($data);
$url = $url.'?'.$params;
$rs = curl_get($url);
//dump($rs);
//return $rs;
//结果处理
//$rs = 'error:111';
//$rs = 'success:122617370809355265322';
if(strpos($rs,'error:') === 0){
$code = substr($rs,6);
return $this->qixunyun_error($code);
}
if(strpos($rs,'success:') === 0){
return true;
}
return '短信发送失败了';
}
public function newsms2(){
$rs = $this->qixunyun_sms('18560505277','123456');
dump($rs);
}
private function qixunyun_error($code){
$array = [
'101' => '缺少name参数',
'102' => '缺少seed参数',
'103' => '缺少key参数',
'104' => '缺少dest参数',
'105' => '缺少content参数',
'106' => 'seed错误',
'107' => 'key错误',
'108' => 'ext错误',
'109' => '内容超长',
'110' => '模板未备案',
'111' => '无签名',
'112' => '缺少pk_total参数',
'113' => '签名不合法',
'114' => '定时时间格式错误',
'115' => '定时时间范围错误',
'116' => '不支持HTTP',
'201' => '无对应账户',
'202' => '账户暂停',
'203' => '账户删除',
'204' => '账户IP没备案',
'205' => '账户无余额',
'206' => '密码错误',
'301' => '无对应产品',
'302' => '产品暂停',
'303' => '产品删除',
'304' => '产品不在服务时间',
'305' => '无匹配通道',
'306' => '通道暂停',
'307' => '通道已删除',
'308' => '通道不在服务时间',
'309' => '未提供短信服务',
'401' => '屏蔽词',
'500' => '查询间隔太短',
'999' => '其他错误',
];
$error = isset($array[$code]) ? $array[$code] : '短信发送失败';
return $error;
}
public function whatsapp_cm(){
$account_id = '657a5348-b28f-4736-8c76-6c47f4b20e4e';
$daibi = '350448a7-e8bc-4310-8d5b-db3518a5d05e';
$url = 'https://gw.cmtelecom.com/v1.0/message';
$client = new \CMText\TextClient('your-api-key');
echo json_encode(
$client->SendMessage('Message_Text', 'CM.com', [ '15866999421' ], 'Your_Reference')
);
}
public function whatapp(){
//临时token
$token = 'EAAGE5ozNog8BO8eXkmeAygGQqEBlIZCTwnPjnZAF7d0f1M5Q1t4IW3GGHAwceY8FR9vkCbZBRHlaMyhDPsFeVaZAFVCbolk4vKvJGMjeG6POOEmPilr5wRvNhjZAnTyYYLZBZBaKPC0mpgvzoVb4OjPA0fXnExlRfPZCg4tQAwxtkFk1UlQRuCchXbxXWDOxiZB05iadOSTf8leHmYeiTHe2hMvkZC4BkZBuIZCfmf1F3qafXZAsHw4uqFfiI';
$token = 'EAAGE5ozNog8BO1ZCLYLW5b4Cl2CAu3YVMPV2jmuuoxxoFpkGmyxvMKZAMaVFTVZAVCFL4AH9MyYZCVezuPSgIxTMRMoZA1yFl5v3G7ZBcz0jXByGjajjWTyPaPnZBgeDrTDK0ZB2FS9aK9gXoftxNpBuklAWns0RAbnEE4aNOMzp2eel5JrkbBW0XFUZAghhzZB3fNnBI8OotMSZBN4NSZA0';
//发送者
$mobile_id = '279740441892291'; //test number :+1 555 609 4631, WhatsApp Business Account ID: 306946452494181
$mobile_id = '308176785712131'; //Elin Dance Stuido:+65 8879 9689 , WhatsApp Business Account ID: 309484315581636
$mobile_id = '337736419413019'; //Elin Dance Stuido 2:+65 8015 4154 , WhatsApp Business Account ID: 336509229537586
//没用的东西
$config_id = '321757761015767';
//接收者
$receive_mobile = '65' . '88799689';
//$receive_mobile = '86' . '15866999421';
//发送
$url = 'https://graph.facebook.com/v19.0/'.$mobile_id.'/messages';
$header = [
'Authorization: Bearer ' . $token,
'Content-Type: application/json',
];
$body = [
'messaging_product' => 'whatsapp',
'recipient_type' => 'individual',
'to' => $receive_mobile,
'type' => 'template',
'template' => [
// 'name' => 'the_class_will_start_tomorrow',
'name' => 'package_expiration_reminder',
'language' => [
// 'code' => 'zh_CN',
'code' => 'en_US'
],
'components' => [
[
'type' => 'body',
'parameters' => [
[
'type' => 'text',
'text' => '张三',
],
[
'type' => 'text',
'text' => '瑜伽课',
],
[
'type' => 'text',
'text' => '2024-05-10 12:30',
],
],
]
],
],
];
$body = json_encode($body);
$rs = curl_post($url,$body,$header);
dump($rs);
}
/*
套餐到期提醒
Package expiration reminder
Hi,{{1}},您购买的套餐{{2}}将于{{3}}过期,建议您在过期内使用完毕!
Hi, {{1}}, the package {{2}} you purchased will expire on {{3}}. We recommend that you use it up within the expiration date!
*/
}