Create the redirect URL for a message.

@param \SAML2\Message $message The message.
@return string The URL the user should be redirected to in order to send a message.
321426
public function getRedirectURL(Message $message) : string
    {
        if ($this->destination === null) {
            $destination = $message->getDestination();
            if ($destination === null) {
                throw new \Exception('Cannot build a redirect URL, no destination set.');
            }
        } else {
            $destination = $this->destination;
        }

        $relayState = $message->getRelayState();

        $key = $message->getSignatureKey();

        $msgStr = $message->toUnsignedXML();

        Utils::getContainer()->debugMessage($msgStr, 'out');
        $msgStr = $msgStr->ownerDocument->saveXML($msgStr);

        $msgStr = gzdeflate($msgStr);
        $msgStr = base64_encode($msgStr);

        /* Build the query string. */

        if ($message instanceof Request) {
            $msg = 'SAMLRequest=';
        } else {
            $msg = 'SAMLResponse=';
        }
        $msg .= urlencode($msgStr);

        if ($relayState !== null) {
            $msg .= '&RelayState='.urlencode($relayState);
        }

        if ($key !== null) { // add the signature
            /** @psalm-suppress PossiblyInvalidArgument */
            $msg .= '&SigAlg='.urlencode($key->type);

            $signature = $key->signData($msg);
            $msg .= '&Signature='.urlencode(base64_encode($signature));
        }

        if (strpos($destination, '?') === false) {
            $destination .= '?'.$msg;
        } else {
            $destination .= '&'.$msg;
        }

        return $destination;
    }
713440
public function translate($message)
    {
        if (isset($this->translations[$message])) {
            return $this->translations[$message];
        } else {
            return $message;
        }
    }
928325
public function sendMessage($message)
    {
        $message = sprintf("%s\r\n", $message);
        fwrite($this->getSocketStream(), $message, strlen($message));
        return $this->receiveMessage();
    }
1315814
public static function createMessage(string $message): string
    {
        $lastErrorMessage = error_get_last();
        if ($lastErrorMessage !== null) {
            $message .= "; ".$lastErrorMessage["message"];
        }
        return $message;
    }
816094
protected function getDecoratedMessage($message, $params = [])
    {
        $result = '';
        $prefix = '';
        foreach ($params as $option => $value) {
            if ($value) {
                $result .= $prefix . $this->decorations[$option][$value];
                $prefix = ';';
            }
        }

        if ($prefix) {
            $message = 'm' . $message;
        }

        return $result . $message;
    }
841353
public function message($to, $message)
    {
        $this->logger->info(sprintf('Sending a message ["%s"] to %s', $message, $to));

        return call_user_func_array([$this->wrapped, 'message'], func_get_args());
    }
937607
public function postMessage(Message $message)
    {
        $options = [
            'text' => $message->getText(),
            'channel' => $message->data['channel'],
            'as_user' => true,
        ];

        if ($message->hasAttachments()) {
            $options['attachments'] = json_encode($message->getAttachments());
        }

        return $this->apiCall('chat.postMessage', $options);
    }
200433
public function redirect($url = '', $message = '', $severity = 'info', $exclude_lang = false)
    {
        $this->setMessage($message, $severity, true);

        $parsed = parse_url($url);

        $query = array();
        if (isset($parsed['query'])) {
            parse_str($parsed['query'], $query);
        }

        $full = strpos($url, $this->base) === 0;
        $this->url->redirect($url, (array) $query, $full, $exclude_lang);
    }
907122
function contact_url( $topic = false, $message = false ) {
            $params = array();
            if ( is_string( $topic ) ) {
                $params['topic'] = $topic;
            }
            if ( is_string( $message ) ) {
                $params['message'] = $message;
            }

            if ( $this->is_addon() ) {
                $params['addon_id'] = $this->get_id();

                return $this->get_parent_instance()->_get_admin_page_url( 'contact', $params );
            } else {
                return $this->_get_admin_page_url( 'contact', $params );
            }
        }
581595
public static function encodeMessage(Message $message): string
    {
        return
            self::encodeHeader($message->getHeader()).
            self::encodeResourceRecords($message->getQuestions()).
            self::encodeResourceRecords($message->getAnswers()).
            self::encodeResourceRecords($message->getAuthoritatives()).
            self::encodeResourceRecords($message->getAdditionals());
    }
747683
protected function applyMessageOptions(Message $message)
    {
        if (empty($this->config['message']['options']) || !is_array($this->config['message']['options'])) {
            return $message;
        }

        foreach ($this->config['message']['options'] as $key => $value) {
            $method = 'set'.ucfirst($key);

            if (is_callable(array($message, $method))) {
                if (!is_array($value)) {
                    $value = array($value);
                }
                call_user_func_array(array($message, $method), $value);
            }
        }

        return $message;
    }
233969
public static function start_message_redirection() {
        if (self::$messagesink) {
            self::stop_message_redirection();
        }
        self::$messagesink = new phpunit_message_sink();
        return self::$messagesink;
    }
736629
public function returnSuccess($message = '操作成功', $url = '', $extra = [])
    {
        if (! empty($this->redirectRoute)) {
            $url = Url::toRoute([
                $this->redirectRoute,
                'msg' => $message,
                'url' => $url,
                $extra
            ]);
        }
        $this->redirect($url);
    }
232343
public function respondCreated($message = "Created")
    {
        $reponse = $this->setStatusCode(ResponseHTTP::HTTP_CREATED)
            ->respondWithMessage($message);
        return $reponse;
    }
100853
public function pinMessage(Message $message)
    {
        $deferred = new Deferred();

        if ($message->pinned) {
            return \React\Promise\reject(new \Exception('This message is already pinned.'));
        }

        if ($message->channel_id != $this->id) {
            return \React\Promise\reject(new \Exception('You cannot pin a message to a different channel.'));
        }

        $this->http->put("channels/{$this->id}/pins/{$message->id}")->then(
            function () use (&$message, $deferred) {
                $message->pinned = true;
                $deferred->resolve($message);
            },
            \React\Partial\bind_right($this->reject, $deferred)
        );

        return $deferred->promise();
    }
714309
public function getRedirectURL(Message $message) : string
    {
        /** @psalm-suppress UndefinedClass */
        $store = Store::getInstance();
        if ($store === false) {
            throw new \Exception('Unable to send artifact without a datastore configured.');
        }

        $generatedId = pack('H*', bin2hex(openssl_random_pseudo_bytes(20)));
        $issuer = $message->getIssuer();
        if ($issuer === null) {
            throw new \Exception('Cannot get redirect URL, no Issuer set in the message.');
        }
        $artifact = base64_encode("\x00\x04\x00\x00".sha1($issuer->getValue(), true).$generatedId);
        $artifactData = $message->toUnsignedXML();
        $artifactDataString = $artifactData->ownerDocument->saveXML($artifactData);

        $store->set('artifact', $artifact, $artifactDataString, Temporal::getTime() + 15*60);

        $params = [
            'SAMLart' => $artifact,
        ];
        $relayState = $message->getRelayState();
        if ($relayState !== null) {
            $params['RelayState'] = $relayState;
        }

        $destination = $message->getDestination();
        if ($destination === null) {
            throw new \Exception('Cannot get redirect URL, no destination set in the message.');
        }
        /** @psalm-suppress UndefinedClass */
        return HTTP::addURLparameters($destination, $params);
    }
241663
protected function isValidMessage($message): Message
    {
        if ($message instanceof Message) {
            return $message;
        }

        if (\is_string($message) || $message instanceof Attachment) {
            return Message::create($message);
        }

        throw new MessengerException(sprintf(
            'message must be a string or an instance of %s or %s.',
            Message::class,
            Attachment::class
        ));
    }