|
|
@@ -260,9 +260,17 @@ class MainController extends BackendController
|
|
|
"keyword2" => ["value" => '客户付款', "color" => "#173177"],
|
|
|
"keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
|
|
|
"remark" => ["value" => "点击查看明细", "color" => "#173177"]]];
|
|
|
- weixinUtil::sendTaskInform($data, $merchant);
|
|
|
-echo 'ok';
|
|
|
-die;
|
|
|
+
|
|
|
+ $accessToken = weixinUtil::getAuthorizerAccessToken($merchant);
|
|
|
+ $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={$accessToken}";
|
|
|
+ //$data = urldecode(json_encode($data, JSON_UNESCAPED_UNICODE));
|
|
|
+ //$curl = new curl\Curl();
|
|
|
+ //$response = $curl->setOption(CURLOPT_POSTFIELDS, $data)->post($url);
|
|
|
+ self::asyncRequest('https://api.weixin.qq.com','/cgi-bin/message/template/send?access_token='.$accessToken,$data);
|
|
|
+ echo 'ok';
|
|
|
+ die;
|
|
|
+
|
|
|
+
|
|
|
sleep(3);
|
|
|
Yii::info('id:'.$_POST['name']);
|
|
|
util::ok();
|
|
|
@@ -272,6 +280,44 @@ die;
|
|
|
return $this->renderPartial('login');
|
|
|
}
|
|
|
|
|
|
+ private static function asyncRequest($host, $path, $param = []){
|
|
|
+
|
|
|
+ $query = isset($param) ? http_build_query($param) : '';
|
|
|
+
|
|
|
+ $port = 80;
|
|
|
+ $errno = 0;
|
|
|
+ $errstr = '';
|
|
|
+ $timeout = 30; //连接超时时间(S)
|
|
|
+
|
|
|
+ $fp = @fsockopen($host, $port, $errno, $errstr, $timeout);
|
|
|
+ //$fp = stream_socket_client("tcp://".$host.":".$port, $errno, $errstr, $timeout);
|
|
|
+
|
|
|
+ if (!$fp) {
|
|
|
+
|
|
|
+ return '连接失败';
|
|
|
+ }
|
|
|
+ if ($errno || !$fp) {
|
|
|
+
|
|
|
+
|
|
|
+ return $errstr;
|
|
|
+ }
|
|
|
+
|
|
|
+ stream_set_blocking($fp,0); //非阻塞
|
|
|
+ stream_set_timeout($fp, 1);//响应超时时间(S)
|
|
|
+ $out = "POST " . $path . " HTTP/1.1\r\n";
|
|
|
+ $out .= "host:" . $host . "\r\n";
|
|
|
+ $out .= "content-length:" . strlen($query) . "\r\n";
|
|
|
+ $out .= "content-type:application/x-www-form-urlencoded\r\n";
|
|
|
+ $out .= "connection:close\r\n\r\n";
|
|
|
+ $out .= $query;
|
|
|
+
|
|
|
+ $result = @fputs($fp, $out);
|
|
|
+
|
|
|
+ @fclose($fp);
|
|
|
+ return $result;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 重复登陆,记录登陆名
|
|
|
* @return string
|