问题
I am trying to add new order in WHMCS.
According to documentation for AddOrder method, it is required to specify an array of base64 encoded serialized array for customfields
and configoptions
parameters.
Example of such method in PHP is described in example:
array(
'action' => 'AddOrder',
....
'customfields' => array(base64_encode(serialize(array("1" => "Google"))), base64_encode(serialize(array("1" => "Google")))),
'configoptions' => array(base64_encode(serialize(array("1" => 999))), base64_encode(serialize(array("1" => 999)))),
....
)
I just wonder how to make similar construction in Python?
Tried to use pickle
and base64.encode
, but no success
tmp = pickle.dumps({"1": "Google"})
customfields = [base64.b64encode(tmp).decode("utf-8")]
Then I pass customfields
to request body, but no success
回答1:
Don't know if this would work but you could give it a try:
tmp = base64.b64encode(b'{"1": "Google"}') customfields = [base64.b64encode(tmp).decode("utf-8")]
来源:https://stackoverflow.com/questions/61796908/python-array-of-base64-encode-and-serialized-array-for-whmcs