<?php namespace App\Service\WechatPlatform; use App\Service\Util\Support\Http\HttpRequestService; use App\Service\Util\Support\Http\WechatURL; use EasyWeChat\OpenPlatform\Application; use Illuminate\Support\Facades\Cache; class GZHSendKFMessageService { /** * 发送文本客服消息 * @param $officialAccount \EasyWeChat\OfficialAccount\Application * @param $openid * @param $content * @param $traceContext * @return bool */ public static function sendText($officialAccount, $openid, $content, $traceContext) { try { $officialAccount->getClient() ->postJson('cgi-bin/message/custom/send', [ 'touser' => $openid, 'msgtype' => 'text', 'text' => [ 'content' => $content ] ])->toArray(); return true; } catch (\Throwable $exception) { myLog('KFMessageSend')->error('发送客服消息失败', [ 'openid' => $openid, 'content' => $content, 'exceptionMsg' => $exception->getMessage(), 'traceInfo' => $traceContext->getTraceInfo() ]); return false; } } }