public function sendTemplateMessageToUser ($templateID, $openID, $url, array $data, array $options = [])
    {
        if (! filter_var($url, FILTER_VALIDATE_URL)) {
            throw new InvalidArgumentException('$url must be a valid URL.');
        }

        $json = json_decode(
            $this->client->send(
                new Request(
                    "POST",
                    "https://api.weixin.qq.com/cgi-bin/message/template/send",
                    [],
                    json_encode(
                        (new Formatter())->formatTemplateMessage(
                            $templateID,
                            $openID,
                            $url,
                            $data,
                            $options
                        )
                    )
                )
            )->getBody()
        );

        if (! isset($json->msgid)) {
            throw new Exception("bad response: expected property `msgid`");
        }

        return $json->msgid;
    }
public function sendTemplateMessageToUser ($templateID, $openID, $url, array $data, array $options = [])
    {
        if (! filter_var($url, FILTER_VALIDATE_URL)) {
            throw new InvalidArgumentException('$url must be a valid URL.');
        }

        $json = json_decode(
            $this->client->send(
                new Request(
                    "POST",
                    "https://api.weixin.qq.com/cgi-bin/message/template/send",
                    [],
                    json_encode(
                        (new Formatter())->formatTemplateMessage(
                            $templateID,
                            $openID,
                            $url,
                            $data,
                            $options
                        )
                    )
                )
            )->getBody()
        );

        if (! isset($json->msgid)) {
            throw new Exception("bad response: expected property `msgid`");
        }

        return $json->msgid;
    }
public function sendTemplateMessageToUser ( $ templateID , $ openID , $ url , array $ data , array $ options = [ ] ) { if ( ! filter_var ( $ url , FILTER_VALIDATE_URL ) ) { throw new InvalidArgumentException ( '$url must be a valid URL.' ) ; } $ json = json_decode ( $ this -> client -> send ( new Request ( "POST" , "https://api.weixin.qq.com/cgi-bin/message/template/send" , [ ] , json_encode ( ( new Formatter ( ) ) -> formatTemplateMessage ( $ templateID , $ openID , $ url , $ data , $ options ) ) ) ) -> getBody ( ) ) ; if ( ! isset ( $ json -> msgid ) ) { throw new Exception ( "bad response: expected property `msgid`" ) ; } return $ json -> msgid ; }
Sends the templated message with the given template id to to specified user.

Returns a message ID that can be used to query the send status of the message at a later stage.

@param string $templateID - The long template ID of the template message to send.
@param string $openID - The Open ID of the recipient.
@param string $url
@param array  $data - Template data parameters to use.
@param array  $options - Additional options to use (currently only supports the `color` option).

@return string

@throws Exception
@throws InvalidArgumentException
Sends the templated message with the given template id to to specified user .