Wubook Login Lost Password

Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wired! php usage. Simple examples does not works.
#3
Thanks for info, i've already realized that even the host url is obsolete. I've started to develop own library based on documentation here:
https://sites.google.com/site/wubookdocs...l-examples

It can manage rooms, prices for defined dates already.
If you are interested i can send it when it will be ready or, if you open for me a repository, we can develop it together.

Here is first lines of it as example:
(any critics, advices, notices will be appreciated!)
PHP Code:
<?
//class KitWuBook

class KitWuBook {
    //vars
    // private $var = 'default';
    const HOST = 'https://wubook.net:443/xrws/';

    private $srv;
    private $acc;
    private $pwd;
    private $lcd;

    private $err;

    //init
    //username, password, enviroment - are usual parameters
    //$lcode = Facility ID, you can find it on Facility->Site tab in WuBook
    //For each facility you will need to create separate object
    function __construct($username, $password, $lcode) {
        
        $this->srv = new xmlrpc_client(self::HOST);
        $this->srv->setSSLVerifyPeer(0);

        $this->acc = $username;
        $this->pwd = $password;
        $this->lcd = (int)$lcode;

        $this->err = '';
    }


    //methods

    //gets the token needed for every xmlrpc query
    private function get_token(){
        $msg = new xmlrpcmsg('get_token',
                               array(new xmlrpcval($this->acc, 'string'),
                                     new xmlrpcval($this->pwd, 'string')));

        $token = $this->srv->send($msg)->serialize()[1];

        return $token;
    }

    //fetches all rooms, attached to current facility
    //result does not consist a price
    public function fetch_rooms(){

        $tok = new xmlrpcval($this->get_token(), 'string');
        $lcd = new xmlrpcval($this->lcd, 'int');

        $msg= new xmlrpcmsg('fetch_rooms', array($tok, $lcd));
        $struct = $this->srv->send($msg);

        $rooms = xmlrpc_decode($struct->serialize())[1];

        return $rooms;
    }

    //fetches defined rooms values or returns all rooms values if not defined last parameter
    public function fetch_rooms_values($fromDate, $toDate, $rooms = array()){
        
        $tok = new xmlrpcval($this->get_token(), 'string');
        $lcd = new xmlrpcval($this->lcd, 'int');
        $frd = new xmlrpcval($fromDate, 'string');
        $tod = new xmlrpcval($toDate, 'string');

        if(sizeof($rooms)>0){ 
            $rms = new xmlrpcval($rooms, 'array');
            $msg= new xmlrpcmsg('fetch_rooms_values', array($tok, $lcd, $frd, $tod, $rms));
        }else{
            $msg= new xmlrpcmsg('fetch_rooms_values', array($tok, $lcd, $frd, $tod));
        }
        
        $rooms_values = xmlrpc_decode($this->srv->send($msg)->serialize())[1];

        return $rooms_values;
    }

    //sets new room values
    //for now works only with 1 defined room
    public function update_rooms_values($fromDate, $roomId, $newPrice, $min_stay = 1, $avail = 1){
        
        $tok   =     new xmlrpcval($this->get_token(), 'string');
        $lcd   =     new xmlrpcval($this->lcd, 'int');
        $frd   =     new xmlrpcval($fromDate, 'string');
        $rid   =    new xmlrpcval($roomId, 'int');
        $prc   =    new xmlrpcval($newPrice, 'double');
        $avl   =    new xmlrpcval($avail, 'int');
        $mst   =    new xmlrpcval($min_stay, 'int');

        $rms =     new xmlrpcval( array(new xmlrpcval( array(
                                                        'id'     => $rid,
                                                        'days'    => new xmlrpcval( array(
                                                                                    new xmlrpcval( array(
                                                                                                    'avail' => $avl,
                                                                                                    'price' => $prc
                                                                                                    ), 'struct'),
                                                                                    new xmlrpcval( array(
                                                                                                    'min_stay' => $mst
                                                                                                    ), 'struct')
                                                                                    ), 'array')
                                                    ),'struct')
                                ) , 'array');

        $msg= new xmlrpcmsg('update_rooms_values', array($tok, $lcd, $frd, $rms));
        
        $answer = xmlrpc_decode($this->srv->send($msg)->serialize());

        return $answer;
    }


... 
  


Messages In This Thread
RE: Wired! php usage. Simple examples does not works. - by EK013 - 06-04-2014, 07:11 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)