To use the Wired functions, you need to acquire a token. Then, the token will be sent as first argument to the available functions.
After the usage, you should release the acquired token to:
release resources on the server side (thanks!)
avoid to be tagged as a flooder (check policies)
Acquiring and releasing a token¶
In order to acquire a token, you’ll have to use the following function:
acquire_token(user, password, provider_key)¶
The arguments user and password are the credentials that a customer uses to enter the WuBook Control Panel.
for Corporate Providers, the Corporate Password can be used for each Corporate SubAccount. So it is possible to provide the SubAccount Code and the Corporate Password instead of the SubAccount Code and SubAccount Password
The acquire_token() function returns a token, which must be treated as a string. For example:
>>> import xmlrpclib >>> server= xmlrpclib.Server(url) >>> returnCode, token= server.acquire_token(user, passwd, pkey) >>> if not returnCode: print 'Acquired token: %s' % token >>> else: print 'Error: %s' % token
your IP matters. Once acquired, the token will work only with the IP from which you acquired it
Here follows an example of the request and response of the acquire token method.
<methodCall> <methodName>acquire_token</methodName> <params> <param> <value> <string>WB001</string> </value> </param> <param> <value> <string>your_account_password</string> </value> </param> <param> <value> <string>your_provider_key</string> </value> </param> </params> </methodCall> <methodResponse> <params> <param> <value> <array> <data> <value> <int>0</int> </value> <value> <string>9869117656.9552</string> </value> </data> </array> </value> </param> </params> </methodResponse>
To release a token, just use the following function (please, release your tokens, once used, to help our servers to be faster):
A great part of the Wired fuctions requires, as second argument, the lcode parameter. The lcode is an integer, uniquely identifying a property (property id).
It can be found by:
Entering the WuBook Control Panel and visiting the Facility/Site section
Using the Corporate Control Panel (if you are a corporate)
Using the Corporate Wired functions (if you are a corporate)
to perform operations against a property, you need to acquire a token using its User Owner (no corporate token, in particular). Why? That’s because from our perspective Wired is not different from the Control Panel, which is under the customer authority. He decides to delegate. Not WuBook for him.
Other token tools¶
The following functions are available:
The is_token_valid() function returns two information. If (and only if) the ReturnCode is zero, it means that the token is valid. In that case, the return value of the function is an integer and represents the number of times that this token has been used.
The provider_info() function is used to return the information WuBook holds about you as Wired Provider. In particular, you can check what email we have registered and associated with your Provider Key. The return value of this function is a Complex Structure. The returned xml is:
<?xml version='1.0'?> <methodResponse> <params> <param> <value><array><data> <value><int>0</int></value> <!-- This is the returnCode: being 0, operation was ok --> <value><struct> <!-- This is the return value, a key->value struct --> <member> <name>info</name> <value><string>Provider Description</string></value> </member> <member> <name>pkey</name> <value><string>YourProviderKey</string></value> </member> <member> <name>emails</name> <value><string>firstname.lastname@example.org email@example.com</string></value> </member> </struct></value> </data></array></value> </param> </params> </methodResponse>
>>> res, d= server.provider_info(token) >>> if res: print 'Error: %s' % d >>> else: >>> for k,v in d.items(): >>> print '%s= %s' % (k, v)