/** * 返回请求短信接口时的 payload * * @param Message $message * @return string * @throws \RuntimeException */ protected function getRequestPayload(Message $message) { $recipients = implode(',', $message->getRecipients()); $data = $message->getData(); return json_encode(['to' => $recipients, 'appId' => $this->appId] + $data); }
/** * 返回请求短信接口时的 payload * * @param Message $message * @return string * @throws \RuntimeException */ protected function getRequestPayload(Message $message) { $recipients = implode(',', $message->getRecipients()); $templateId = (string) $message->getTemplateId(); $data = $message->getData(); array_walk($data, function (&$item) { $item = (string) $item; }); $data = array_values($data); return json_encode(['to' => $recipients, 'appId' => $this->appId, 'templateId' => $templateId, 'datas' => $data]); }