|
|
@@ -10,37 +10,41 @@ use linslin\yii2\curl;
|
|
|
class noticeUtil
|
|
|
{
|
|
|
|
|
|
- public static function push($message,$mobile_list = [])
|
|
|
- {
|
|
|
- $url = "https://oapi.dingtalk.com/robot/send?access_token=0856d031e07890f1902496747a0576a49c3df51dcf1e16427168cce12892bedb";
|
|
|
- $data = [
|
|
|
- 'msgtype' => 'text',
|
|
|
- 'text' => ['content' => '【花卉宝】'.$message]
|
|
|
- ];
|
|
|
- if(!empty($mobile_list)){
|
|
|
- $mobile_list = is_array($mobile_list) == false ? [(string)$mobile_list] : $mobile_list;
|
|
|
- $data['at']['atMobiles'] = $mobile_list;
|
|
|
- }
|
|
|
-
|
|
|
- $data_string = json_encode($data);
|
|
|
- self::request($url, $data_string);
|
|
|
- }
|
|
|
+ public static function push($message, $mobile_list = [])
|
|
|
+ {
|
|
|
+ if (getenv('YII_ENV') == 'production') {
|
|
|
+ $url = "https://oapi.dingtalk.com/robot/send?access_token=0856d031e07890f1902496747a0576a49c3df51dcf1e16427168cce12892bedb";
|
|
|
+ } else {
|
|
|
+ $url = 'https://oapi.dingtalk.com/robot/send?access_token=0809902bdb8fa5cfdddbbe36cf3d061558c87769a38c03168571a41913e0d238';
|
|
|
+ }
|
|
|
+ $data = [
|
|
|
+ 'msgtype' => 'text',
|
|
|
+ 'text' => ['content' => '【花卉宝】' . $message]
|
|
|
+ ];
|
|
|
+ if (!empty($mobile_list)) {
|
|
|
+ $mobile_list = is_array($mobile_list) == false ? [(string)$mobile_list] : $mobile_list;
|
|
|
+ $data['at']['atMobiles'] = $mobile_list;
|
|
|
+ }
|
|
|
|
|
|
- public static function request($remote_server, $post_string)
|
|
|
- {
|
|
|
- $ch = curl_init();
|
|
|
- curl_setopt($ch, CURLOPT_URL, $remote_server);
|
|
|
- curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
|
|
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json;charset=utf-8'));
|
|
|
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
|
|
|
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
- // 线下环境不用开启curl证书验证, 未调通情况可尝试添加该代码
|
|
|
- // curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|
|
- // curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
|
|
- $data = curl_exec($ch);
|
|
|
- curl_close($ch);
|
|
|
- return $data;
|
|
|
- }
|
|
|
+ $data_string = json_encode($data);
|
|
|
+ self::request($url, $data_string);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function request($remote_server, $post_string)
|
|
|
+ {
|
|
|
+ $ch = curl_init();
|
|
|
+ curl_setopt($ch, CURLOPT_URL, $remote_server);
|
|
|
+ curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
|
|
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json;charset=utf-8'));
|
|
|
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
+ // 线下环境不用开启curl证书验证, 未调通情况可尝试添加该代码
|
|
|
+ // curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|
|
+ // curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
|
|
+ $data = curl_exec($ch);
|
|
|
+ curl_close($ch);
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
|
|
|
}
|