0 && $sceneValue < self::SCENE_MAX_VALUE) { $type = self::SCENE_QR_FOREVER; $sceneKey = 'scene_id'; } else { $type = self::SCENE_QR_FOREVER_STR; $sceneKey = 'scene_str'; } $scene = [$sceneKey => $sceneValue]; return $this->create($type, $scene, false)->toArray(); } /** * 临时二维码生成 * @param int|string $sceneValue * @param int|null $expireSeconds * @return array|mixed[] * @throws TransportExceptionInterface * @throws \EasyWeChat\Kernel\Exceptions\BadResponseException * @throws \Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface * @throws \Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface * @throws \Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface * @throws \Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface */ public function temporary(int|string $sceneValue, ?int $expireSeconds = null): array { if (is_int($sceneValue) && $sceneValue > 0) { $type = self::SCENE_QR_TEMPORARY; $sceneKey = 'scene_id'; } else { $type = self::SCENE_QR_TEMPORARY_STR; $sceneKey = 'scene_str'; } $scene = [$sceneKey => $sceneValue]; return $this->create($type, $scene, true, $expireSeconds)->toArray(); } /** * 创建二维码 * @param $actionName * @param $actionInfo * @param bool $temporary * @param null $expireSeconds * @return Response|ResponseInterface * @throws TransportExceptionInterface * @author 等风来 * @email 136327134@qq.com * @date 2023/9/15 */ protected function create($actionName, $actionInfo, bool $temporary = true, $expireSeconds = null): ResponseInterface|Response { null !== $expireSeconds || $expireSeconds = 7 * self::DAY; $params = [ 'action_name' => $actionName, 'action_info' => ['scene' => $actionInfo], ]; if ($temporary) { $params['expire_seconds'] = min($expireSeconds, 30 * self::DAY); } return $this->api->postJson('cgi-bin/qrcode/create', $params); } }