3]); $httpResult = $client->get('https://api.weixin.qq.com/cgi-bin/token', [ 'query' => ['grant_type' => 'client_credential', 'appid' => $appid, 'secret' => $secret] ]); if(200 != $httpResult->getStatusCode()) { throw new \RuntimeException('请求微信上游失败', '500001'); } $parsedContent = \json_decode($httpResult->getBody()->getContents(), true); if(0 != ($parsedContent['errcode'] ?? 0)) { throw new \RuntimeException('请求微信上游失败:'. ($parsedContent['errmsg'] ?? ''), '500002'); } return $parsedContent; } public static function getAccessTokenRedisKey($appid) { return 'dj.miniWechat.at.' . $appid; } }