1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace huomp\controller\sec;
- use huo\controller\common\Base;
- use huolib\status\CommonStatus;
- use huoMpMsg\controller\Common;
- class secCheckApi extends Base {
-
- public function msgSecCheck($wx_app_id, $wx_app_secret, $content) {
- $_url = 'https://api.weixin.qq.com/wxa/msg_sec_check';
- $_access_token = Common::getAccessToken($wx_app_id, $wx_app_secret);
- $_url = $_url.'?access_token='.$_access_token;
- $_param = ['content' => $content];
- $_param_json = json_encode($_param, JSON_UNESCAPED_UNICODE);
- $_header = ['Content-Type: application/octet-stream; charset=utf-8'];
- $_ret = Common::curl($_url, $_param_json, 'POST', $_header);
- $_rdata = [];
- if (Common::isJson($_ret)) {
- $_rdata = json_decode($_ret, true);
- }
- if (isset($_rdata['errcode']) && '0' != $_rdata['errcode']) {
- $_code = $_rdata['errcode'];
- return $this->huoError($_code, $_rdata['errmsg']);
- }
- $_code = CommonStatus::NO_ERROR;
- return $this->huoSuccess($_code, CommonStatus::getMsg($_code));
- }
-
- public function imgSecCheck($wx_app_id, $wx_app_secret, $file) {
- $_url = 'https://api.weixin.qq.com/wxa/img_sec_check';
- $_access_token = Common::getAccessToken($wx_app_id, $wx_app_secret);
- $_url = $_url.'?access_token='.$_access_token;
- $cfile = curl_file_create($file);
- $_img_data = array('media' => $cfile);
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $_url);
- curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data'));
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_POST, 1);
- curl_setopt($curl, CURLOPT_POSTFIELDS, $_img_data);
-
- if (strlen($_url) > 5 && strtolower(substr($_url, 0, 5)) == "https") {
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
- }
- $_ret = curl_exec($curl);
- if (false === $_ret) {
- $_ret = curl_errno($curl);
- }
- curl_close($curl);
- if (Common::isJson($_ret)) {
- $_rdata = json_decode($_ret, true);
- }
- if (isset($_rdata['errcode']) && '0' != $_rdata['errcode']) {
- $_code = $_rdata['errcode'];
- return $this->huoError($_code, $_rdata['errmsg']);
- }
- $_code = CommonStatus::NO_ERROR;
- return $this->huoSuccess($_code, CommonStatus::getMsg($_code));
- }
- }
|