Common API - Obtain authorization token interface
Obtain authorization token interface
Interface Description:
Tokens required to access other interfaces must be obtained from this interface through the authorized Appid and Accesskey (except for the batch IVR interface). The timeliness of the interface authorization Token is 12 hours.
Request method: POST, form-data format
request parameters
parameter name |
type |
Is it necessary |
illustrate |
appid |
string |
yes |
authorized appid |
accesskey |
string |
yes |
authorized accesskey |
service |
string |
yes |
App.Sip_Auth.Login |
Interface request example(PHP)
<?php
$apiUrl = 'http://127.0.0.1:8080';
$postFields = [
'service' => 'App.Sip_Auth.Login',
'appid' => 'ABCDEFG',
'accesskey' => 'ABCDEFG',
];
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $apiUrl);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl);
$curlError = curl_error($curl);
curl_close($curl);
var_dump($response);
?>
返回数据结构示例
{
"ret":200,
"data":{
"status":0,
"desc":"Authorization successful",
"result":{
"companycode":"1",
"companyname":"test",
"token":"773a70dd02f0695d50205e9b267692b9",
"authtime":"2020-01-01 00:00:00",
"authmodel":""
},
"reqtime":1581240882,
"rsptime":1581240882
},
"msg":""
}
Return parameter description
parameter name |
type |
illustrate |
companycode |
int |
Company code |
companyname |
string |
Company Name |
token |
string |
Authorization token, used to access other interfaces |