R
R
rumsey2018-03-18 16:33:09
Python
rumsey, 2018-03-18 16:33:09

An example of working with the Mango-office API in python?

Does anyone have an example of working with this API?
Interested in how to calculate the hash and an example of a POST request with json?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rumsey, 2018-03-21
@rumsey

Figured it out myself.
Might be useful to someone:

mango_json = {
    "command_id": "sms",
    "text": sms_text,
    "from_extension": "111",
    "to_number":  phone_number,
    "sms_sender": "name"
}
# генерируем подпись
sign = sha256(settings.MANGO_API_KEY + json.dumps(mango_json) + settings.MANGO_SALT).hexdigest()
data = {
    'vpbx_api_key': settings.MANGO_API_KEY,
    'sign': sign,
    'json': json.dumps(mango_json)
}
requests.post(self.sms_api_url, data=data)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question