IXR_Message example

if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {
                if ( function_exists( 'status_header' ) ) {
                    status_header( 405 ); // WP #20986                     header( 'Allow: POST' );
                }
                header('Content-Type: text/plain'); // merged from WP #9093                 die('XML-RPC server accepts POST requests only.');
            }

            $data = file_get_contents('php://input');
        }
        $this->message = new IXR_Message($data);
        if (!$this->message->parse()) {
            $this->error(-32700, 'parse error. not well formed');
        }
        if ($this->message->messageType != 'methodCall') {
            $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
        }
        $result = $this->call($this->message->methodName, $this->message->params);

        // Is the result an error?         if (is_a($result, 'IXR_Error')) {
            $this->error($result);
        }
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
            $this->error = new IXR_Error( -32301, 'transport error - HTTP status code was not 200 (' . wp_remote_retrieve_response_code( $response ) . ')' );
            return false;
        }

        if ( $this->debug ) {
            echo '<pre class="ixr_response">' . htmlspecialchars( wp_remote_retrieve_body( $response ) ) . "\n</pre>\n\n";
        }

        // Now parse what we've got back.         $this->message = new IXR_Message( wp_remote_retrieve_body( $response ) );
        if ( ! $this->message->parse() ) {
            // XML error.             $this->error = new IXR_Error( -32700, 'parse error. not well formed' );
            return false;
        }

        // Is the message a fault?         if ( 'fault' === $this->message->messageType ) {
            $this->error = new IXR_Error( $this->message->faultCode, $this->message->faultString );
            return false;
        }

        
                $contents .= $line;
            }
            if ($this->debug) {
                $debugContents .= $line;
            }
        }
        if ($this->debug) {
            echo '<pre class="ixr_response">'.htmlspecialchars($debugContents)."\n</pre>\n\n";
        }

        // Now parse what we've got back         $this->message = new IXR_Message($contents);
        if (!$this->message->parse()) {
            // XML error             $this->error = new IXR_Error(-32700, 'parse error. not well formed');
            return false;
        }

        // Is the message a fault?         if ($this->message->messageType == 'fault') {
            $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
            return false;
        }

        
Home | Imprint | This part of the site doesn't use cookies.