You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
information-system/webht/third_party/messagecenter/controllers/index.php

183 lines
5.4 KiB
PHP

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Index extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->helper('message');
$this->key = '3d15821171548bf7d0a93afab66e797b';
$this->sendsms = 'https://yun.tim.qq.com/v5/tlssmssvr/sendsms';
}
public function test(){
echo phpinfo();
/*try {
echo '1';
} finally {
echo '2';
}*/
}
public function index(){
$this->load->view('n-header');
$this->load->view('message_index');
}
//新建短信模板
public function add_templete(){
$templete = htmlspecialchars($this->input->post('templete'));
$title = $this->input->post('title');
if(empty($templete)){
header("HTTP/1.1 404 Not Found");
exit('{"status":"404","reason":"传参为空!"}');
}
if(empty($title)){
$title = 'trippset'.rand(1,100);
}
$random = rand(1000,9999);
$time = time();
$sig = 'appkey='.$this->key.'&random='.$random.'&time='.$time;
$sig = hash("sha256", $sig);
$post_str = '{
"remark": "",
"sig": "'.$sig.'",
"text": "'.$templete.'",
"time": '.$time.',
"title": "'.$title.'",
"type": 1
}';
$url = 'https://yun.tim.qq.com/v5/tlssmssvr/add_template?sdkappid=1400082793&random='.$random;
$back_json = sms_post($url,$post_str,'POST');
$back_data = json_decode($back_json);
print_r($back_data);
}
//查询短信模板状态
public function search_templete_status(){
$random = rand(1000,9999);
$time = time();
$sig = 'appkey='.$this->key.'&random='.$random.'&time='.$time;
$sig = hash("sha256", $sig);
$post_str = '{
"sig": "'.$sig.'",
"time": '.$time.',
"tpl_page": {
"max": 10,
"offset": 0
}
}';
$url = 'https://yun.tim.qq.com/v5/tlssmssvr/get_template?sdkappid=1400082793&random='.$random;
$back_json = sms_post($url,$post_str,'POST');
$back_data = json_decode($back_json);
print_r($back_data);
}
//短信模板更新
public function update_templete($id,$title){
$contents = "Hi {1}, your guide on {2} is {3}, localmobile is {4}. He/she'll call you at the hotel, or leave a message tonight. You can find more info by inputting booking No. {5} at https://www.trippest.com/track-your-trip. Wish you a wonderful day with Trippest!";
$random = rand(1000,9999);
$time = time();
$sig = 'appkey='.$this->key.'&random='.$random.'&time='.$time;
$sig = hash("sha256", $sig);
$post_str = '{
"sig": "'.$sig.'",
"text": "'.$contents.'",
"time": '.$time.',
"title": "'.$title.'",
"tpl_id": '.$id.',
"type": 0
}';
$url = 'https://yun.tim.qq.com/v5/tlssmssvr/mod_template?sdkappid=1400082793&random='.$random;
$back_json = sms_post($url,$post_str,'POST');
$back_data = json_decode($back_json);
print_r($back_data);
}
//删除模板
public function delete_templete(){
$random = rand(1000,9999);
$time = time();
$sig = 'appkey='.$this->key.'&random='.$random.'&time='.$time;
$sig = hash("sha256", $sig);
$post_str = '{
"sig": "'.$sig.'",
"time": '.$time.',
"tpl_id": [
212919,
213082
]
}';
$url = 'https://yun.tim.qq.com/v5/tlssmssvr/del_template?sdkappid=1400082793&random='.$random;
$back_json = sms_post($url,$post_str,'POST');
$back_data = json_decode($back_json);
print_r($back_data);
}
//发送短信
public function send_message(){
//接收参数
//1-4为四个参数依次排序 字符格式不做限制
$one = $this->input->post('one');
$two = $this->input->post('two');
$three = $this->input->post('three');
$four = $this->input->post('four');
$five = $this->input->post('five');
//手机号 * 必填
$phone = $this->input->post('phone');
//区号 * 必填
$nation_code = $this->input->post('nation_code');
if(empty($phone) || empty($nation_code)){
header("HTTP/1.1 404 Not Found");
exit('{"status":"404","reason":"传参为空!"}');
}
//构造发送短信的报文
$random = rand(1000,9999);
$time = time();
$sig = 'appkey='.$this->key.'&random='.$random.'&time='.$time.'&mobile='.$phone;
$sig = hash("sha256", $sig);
$mysign = '[ChinaHighlights]';
if($nation_code == 86){
$mysign = '【桂林海纳国旅】';
}
$post_str = '{
"ext": "",
"extend": "",
"msg": "Hi '.$one.', your guide on '.$two.' is '.$three.', (local) mobile is '.$four.'. He/she\'ll call you at the hotel, or leave a message tonight. You can find more info by inputting booking No. '.$five.' at https://www.trippest.com/track-your-trip. Wish you a wonderful day with Trippest!",
"sig": "'.$sig.'",
"tel": {
"mobile": "'.$phone.'",
"nationcode": "'.$nation_code.'"
},
"time": '.$time.',
"type": 0
}';
$url = 'https://yun.tim.qq.com/v5/tlssmssvr/sendsms?sdkappid=1400082793&random='.$random;
$back_json = sms_post($url,$post_str,'POST');
$back_data = json_decode($back_json);
print_r($back_json);
}
}
?>