1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- /**
- * 对接crm接口
- */
- class Model_logic_ding extends Lin_Model {
- function __construct(){
- parent::__construct();
- $this->load->_model("Model_logic_tools","logic_tools");
- }
- public $key = "ly20250115@0911";
- //public $key = "Hello, World!";
- public function getKey(){
- return $this->key;
- }
- public $url = "https://1.wepolicy.cn/errorlog/ding";
- //public $url = "http://cerp.wepolicy.cn/errorlog/ding";
- public function sendToDing($error_msg){
- $data = [
- 'bs'=>$this->logic_tools->toolsjiami($this->key),
- 'content'=>$error_msg,
- ];
- $data = json_encode($data,JSON_UNESCAPED_UNICODE);
- $ch = curl_init($this->url);
- // 设置cURL选项
- $options = array(
- CURLOPT_SSL_VERIFYPEER=>false,
- CURLOPT_SSL_VERIFYHOST=>false,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_POST => true,
- CURLOPT_POSTFIELDS => $data,
- CURLOPT_HTTPHEADER => [
- 'Content-Type: application/json'
- ],
- CURLOPT_ENCODING => "gzip,deflate"
- );
- // 应用这些选项到cURL会话
- curl_setopt_array($ch, $options);
- // 执行cURL会话并获取响应
- $response = curl_exec($ch);
-
-
- // 检查是否有错误发生
- if ($response === false) {
- $error = curl_error($ch);
- curl_close($ch);
- return [
- "code"=> -1,
- "msg"=> $error
- ];
- }
-
- // 关闭cURL会话
- curl_close($ch);
- }
- }
|