[{"content":{"version":1,"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"В разделе "},{"type":"text","text":"authentication ","marks":[{"type":"strong"}]},{"type":"text","text":"в поля "},{"type":"text","text":"client_id ","marks":[{"type":"strong"}]},{"type":"text","text":"и "},{"type":"text","text":"client_secret ","marks":[{"type":"strong"}]},{"type":"text","text":"требуется ввести полученные при регистрации приложения значения "},{"type":"text","text":"Application_ID ","marks":[{"type":"strong"}]},{"type":"text","text":"и "},{"type":"text","text":"Application_Secret","marks":[{"type":"strong"}]},{"type":"text","text":", затем нажать на кнопку "},{"type":"text","text":"\"Try it out!\"","marks":[{"type":"strong"}]},{"type":"text","text":". Если данные приложения верны, в ответ вернётся токен доступа ("},{"type":"text","text":"access_token","marks":[{"type":"strong"}]},{"type":"text","text":"). Полученный токен доступа следует ввести в поле \""},{"type":"text","text":"Access Token Field","marks":[{"type":"strong"}]},{"type":"text","text":"\" вверху страницы и сохранить его нажатием кнопки "},{"type":"text","text":"\"Set Token\"","marks":[{"type":"strong"}]},{"type":"text","text":"."}]},{"type":"table","attrs":{"isNumberColumnEnabled":false,"layout":"default"},"content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"метод","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"ресурс","marks":[{"type":"strong"}]}]}]},{"type":"tableHeader","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"данные","marks":[{"type":"strong"}]}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"GET"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"/client/@me/calls/stats/?start_datetime=2019-11-01%2000%3A00%3A00&end_datetime=2019-11-10%2000%3A00%3A00"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[]},{"type":"paragraph","content":[{"type":"text","text":" "}]}]}]}]},{"type":"paragraph","content":[]}]},"id":"a1164bfc-edfe-4604-bd55-86718a211f6c","label":"Интерактивный обозреватель API ","type":"tab"},{"content":{"version":1,"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Для отправки запросов с помощью программы cURL установим значения переменных "},{"type":"text","text":"url ","marks":[{"type":"strong"}]},{"type":"text","text":"и "},{"type":"text","text":"access_token","marks":[{"type":"strong"}]},{"type":"text","text":":"}]},{"type":"paragraph","content":[{"type":"text","text":"export url=\"https://<hostname>/api/ver1.0\"","marks":[{"type":"code"}]},{"type":"text","text":" "},{"type":"hardBreak"},{"type":"text","text":"(где hostname — hostname API-сервера провайдера IP-телефонии),"}]},{"type":"paragraph","content":[{"type":"text","text":"export access_token=\"8SNsrS0jV35vfmKqKeKtRrHfpbg4UX\"","marks":[{"type":"code"}]},{"type":"text","text":" "},{"type":"hardBreak"},{"type":"text","text":"(полученный токен доступа)."}]},{"type":"paragraph","content":[{"type":"text","text":"Отправим запрос:"}]},{"type":"codeBlock","attrs":{"language":"shell"},"content":[{"type":"text","text":"curl \\\n-H \"Authorization: Bearer ${access_token}\" \\\n-X GET \"${url}/client/@me/calls/stats/?start_datetime=2019-11-01%2000:00:00&end_datetime=2019-11-10%2000:00:00\""}]}]},"id":"e574abcf-fe3d-4bf5-b84e-11683f2434f8","label":"Программа cURL ","type":"tab"},{"content":{"version":1,"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Для отправки запросов на языке Python установим значения переменных URL и ACCESS_TOKEN:"}]},{"type":"paragraph","content":[{"type":"text","text":"URL = \"https://<hostname>/api/ver1.0\"","marks":[{"type":"code"}]},{"type":"hardBreak"},{"type":"text","text":"(где hostname — hostname API-сервера провайдера IP-телефонии),"}]},{"type":"paragraph","content":[{"type":"text","text":"ACCESS_TOKEN = \"8SNsrS0jV35vfmKqKeKtRrHfpbg4UX\"","marks":[{"type":"code"}]},{"type":"hardBreak"},{"type":"text","text":"(полученный токен доступа)."}]},{"type":"codeBlock","attrs":{"language":"python"},"content":[{"type":"text","text":"#!/usr/bin/python\n\nimport requests\n\nurl = f'{URL}/client/@me/calls/stats/?start_datetime=2019-11-01%2000%3A00%3A00&end_datetime=2019-11-10%2000%3A00%3A00'\nheaders = {\n 'Authorization': f'Bearer {ACCESS_TOKEN}'\n}\nresponse = requests.get(url, headers=headers)\nprint(response.text)"}]}]},"id":"349a32fd-ad31-469e-8040-ae951e47e23d","label":"На языке Python3 ","type":"tab"}] |