Welcome Guest, Not a member yet? Register   Sign In
connect to xmlrpc behind http auth
#2

[eluser]pistolPete[/eluser]
You probably have to subclass the core class XML_RPC_Client and modify the function sendPayload():
Code:
function sendPayload($msg)
    {    
        $fp = @fsockopen($this->server, $this->port,$this->errno, $this->errstr, $this->timeout);
        
        if ( ! is_resource($fp))
        {
            error_log($this->xmlrpcstr['http_error']);
            $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'],$this->xmlrpcstr['http_error']);
            return $r;
        }
        
        if(empty($msg->payload))
        {
            // $msg = XML_RPC_Messages
            $msg->createPayload();
        }
        
        $r = "\r\n";
        $op  = "POST {$this->path} HTTP/1.0$r";
        $op .= "Host: {$this->server}$r";
        $op .= "Content-Type: text/xml$r";
        $op .= "User-Agent: {$this->xmlrpcName}$r";
        
        //Added "basic access authentication":
        $op .= "Authorization: Basic ".base64_encode("$username:$password").$r;
        
        $op .= "Content-Length: ".strlen($msg->payload). "$r$r";
        $op .= $msg->payload;
        

        if ( ! fputs($fp, $op, strlen($op)))
        {
            error_log($this->xmlrpcstr['http_error']);
            $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']);
            return $r;
        }
        $resp = $msg->parseResponse($fp);
        fclose($fp);
        return $resp;
    }

You'd then have to extend the parent class in order to hand on $username and $password.


Messages In This Thread
connect to xmlrpc behind http auth - by El Forum - 04-09-2009, 06:38 AM
connect to xmlrpc behind http auth - by El Forum - 04-09-2009, 07:01 AM
connect to xmlrpc behind http auth - by El Forum - 02-08-2011, 05:53 AM
connect to xmlrpc behind http auth - by El Forum - 04-26-2011, 12:55 AM
connect to xmlrpc behind http auth - by El Forum - 04-26-2011, 06:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB