From 22d3d9eff0883961e8a393983c0129a22bc39891 Mon Sep 17 00:00:00 2001 From: yiwangchunyu Date: Mon, 25 Feb 2019 22:26:03 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=8D=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- edit/edit.php | 11 ++++++---- lib/SensitiveWordDetection.php | 38 ++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/edit/edit.php b/edit/edit.php index 8c502c7..262100d 100755 --- a/edit/edit.php +++ b/edit/edit.php @@ -20,12 +20,15 @@ $msg = $_GET['msg']; $ie = $_GET['image_exist']; -$res = \lib\SensitiveWordDetection::send($title.$msg); +$res = \lib\SensitiveWordDetection::sendSwc($title.$msg); if($res['status']='00000'){ - if($res['result']==true){ - $rr->send(-2,"您所发的内容包含敏感词汇!",$res); - } +// if($res['result']==true){ +// $rr->send(-2,"您所发的内容包含敏感词汇!",$res); +// } + $msg = $res['result']; + $log = new \lib\Log(); + $log->debug(json_encode($res)); }else{ $rr->send(-1,"网络错误,请稍后重试!",$res); } diff --git a/lib/SensitiveWordDetection.php b/lib/SensitiveWordDetection.php index 7860344..30d6b67 100755 --- a/lib/SensitiveWordDetection.php +++ b/lib/SensitiveWordDetection.php @@ -22,9 +22,8 @@ public function __construct() $this->log = new \lib\Log(); } - public static function send($querys){ + public static function sendSwc($querys){ $host = "http://apistore.tongchengyue.com"; -// $path = "/sw/isContains"; $path = "/swc/doFilter"; $method = "POST"; $appcode = "f560138f1b514ca98e7cf8ca12a23d85"; @@ -32,6 +31,41 @@ public static function send($querys){ array_push($headers, "Authorization:APPCODE " . $appcode); //根据API的要求,定义相对应的Content-Type array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8"); + $querys = ""; + $bodys = "src=".$querys; + $url = $host . $path; + + $curl = curl_init(); + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + curl_setopt($curl, CURLOPT_FAILONERROR, false); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_HEADER, true); + if (1 == strpos("$".$host, "https://")) + { + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); + } + curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys); + $response = curl_exec($curl); + if (curl_getinfo($curl, CURLINFO_HTTP_CODE) == '200') { + list($resHeader, $resBody) = explode("\r\n\r\n", $response, 2); + } + $resBody = json_decode($resBody,true); + return $resBody; + } + + public static function send($querys){ + $host = "http://apistore.tongchengyue.com"; + $path = "/sw/isContains"; +// $path = "/swc/doFilter"; + $method = "POST"; + $appcode = "f560138f1b514ca98e7cf8ca12a23d85"; + $headers = array(); + array_push($headers, "Authorization:APPCODE " . $appcode); + //根据API的要求,定义相对应的Content-Type + array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8"); // $querys = ""; $bodys = "src=".$querys; $url = $host . $path; From 0f71a9122c14cf12ef28890aa5a108f29042de5d Mon Sep 17 00:00:00 2001 From: yiwangchunyu Date: Mon, 25 Feb 2019 22:43:13 +0800 Subject: [PATCH 2/4] debug --- lib/SensitiveWordDetection.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/SensitiveWordDetection.php b/lib/SensitiveWordDetection.php index 30d6b67..5a8c6b5 100755 --- a/lib/SensitiveWordDetection.php +++ b/lib/SensitiveWordDetection.php @@ -49,6 +49,8 @@ public static function sendSwc($querys){ } curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys); $response = curl_exec($curl); + $log = new \lib\Log(); + $log->debug(json_encode($response)); if (curl_getinfo($curl, CURLINFO_HTTP_CODE) == '200') { list($resHeader, $resBody) = explode("\r\n\r\n", $response, 2); } From 841874a15068d8d1328386a4123002bf7ebd0771 Mon Sep 17 00:00:00 2001 From: yiwangchunyu Date: Mon, 25 Feb 2019 22:59:35 +0800 Subject: [PATCH 3/4] bugfix --- edit/edit.php | 4 +--- lib/SensitiveWordDetection.php | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/edit/edit.php b/edit/edit.php index 262100d..d1048ec 100755 --- a/edit/edit.php +++ b/edit/edit.php @@ -22,13 +22,11 @@ $res = \lib\SensitiveWordDetection::sendSwc($title.$msg); -if($res['status']='00000'){ +if($res['status']=='00000'){ // if($res['result']==true){ // $rr->send(-2,"您所发的内容包含敏感词汇!",$res); // } $msg = $res['result']; - $log = new \lib\Log(); - $log->debug(json_encode($res)); }else{ $rr->send(-1,"网络错误,请稍后重试!",$res); } diff --git a/lib/SensitiveWordDetection.php b/lib/SensitiveWordDetection.php index 5a8c6b5..6479da4 100755 --- a/lib/SensitiveWordDetection.php +++ b/lib/SensitiveWordDetection.php @@ -31,7 +31,7 @@ public static function sendSwc($querys){ array_push($headers, "Authorization:APPCODE " . $appcode); //根据API的要求,定义相对应的Content-Type array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8"); - $querys = ""; +// $querys = ""; $bodys = "src=".$querys; $url = $host . $path; @@ -49,8 +49,6 @@ public static function sendSwc($querys){ } curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys); $response = curl_exec($curl); - $log = new \lib\Log(); - $log->debug(json_encode($response)); if (curl_getinfo($curl, CURLINFO_HTTP_CODE) == '200') { list($resHeader, $resBody) = explode("\r\n\r\n", $response, 2); } From f6e82c0c7913d44a00874731f4a351ae7ab4588d Mon Sep 17 00:00:00 2001 From: yiwangchunyu Date: Sat, 20 Apr 2019 00:12:18 +0800 Subject: [PATCH 4/4] openid --- getopenid.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/getopenid.php b/getopenid.php index bbc4bcc..4113cf2 100755 --- a/getopenid.php +++ b/getopenid.php @@ -2,7 +2,7 @@ $data = $_GET; //echo json_encode($data); $appid="wxd8d5a2f6fa7f1878"; - $appsecret="064157612113b2490b1941c7b0e77fda"; + $appsecret="001gjwq00HrkqH14SDs00PXMq00gjwq4"; $code=$_GET['code']; $get_url="https://api.weixin.qq.com/sns/jscode2session?appid=".$appid."&secret=".$appsecret."&js_code=".$code."&grant_type=authorization_code"; $get_return = file_get_contents($get_url);