/** * 微信客服回复函数 */ private function wxServiceRepeat($UserId, $msg) { $wxChat = new JSSDKModel(); $Token = $wxChat->GetToken(); $UserModel = new UserModel(); $UserResult = $UserModel->GetUserInfo($UserId); $data['touser'] = $UserResult['openid']; $data['msgtype'] = 'text'; $data['text'] = array('content' => $msg); $data = $this->encode_json($data); $url = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=' . $Token; $header = array('Content-Type: application/json; charset=utf-8', 'Content-Length: ' . strlen($data)); $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // The maximum number of seconds to allow cURL functions to execute. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); $response = curl_exec($ch); if (curl_errno($ch)) { return false; //return curl_errno($ch); } curl_close($ch); if (!isset($response['errcode'])) { return true; } else { return false; } }