1.3获取api_key(账号密码方式)
<p><strong>简要描述:</strong> </p>
<ul>
<li>获取api_key接口作为其他接口的基础接口,主要通过此接口获得api_key跟user_sn用于请求其他接口,api_key有效时间为俩小时,过期了需要重新请求一次登录接口获得新的api_key,可以将api_key缓存起来。同一账号被多用户调用登录接口时,会导致一方api_key失效,多用户需要用api_key的时候可以使用同一个缓存起来的api_key。</li>
</ul>
<p><strong>请求URL:</strong> </p>
<ul>
<li><code>/api/login</code></li>
</ul>
<p><strong>请求方式:</strong></p>
<ul>
<li>POST </li>
</ul>
<p><strong>参数:</strong> </p>
<table>
<thead>
<tr>
<th style="text-align: left;">参数名</th>
<th style="text-align: left;">必选</th>
<th style="text-align: left;">类型</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">username</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">string</td>
<td>用户名</td>
</tr>
<tr>
<td style="text-align: left;">password</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">string</td>
<td>密码</td>
</tr>
<tr>
<td style="text-align: left;">from</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">string</td>
<td>请求来自哪个客户端 填2 (表示接口登录)</td>
</tr>
<tr>
<td style="text-align: left;">url</td>
<td style="text-align: left;">是</td>
<td style="text-align: left;">String</td>
<td>防劫持字符串</td>
</tr>
</tbody>
</table>
<h5>参数url说明:</h5>
<p>将除了url外的所有请求参数(包括公共参数和方法参数)编码成json格式,然后md5(32位小写)加密后得到的字符串,从第二个字符开始,截取8位生成,注意:加密的json数据不能带空格、换行符等。md5之前,可以通过一个函数(自定义或者自带)去掉换行符跟空格。注意:每个接口都需要传入此参数,此参数会根据你传入的json不同而不同,所以每次请求需要重新MD5得到新的url,<strong>加密的JSON跟GET/POST所传的参数顺序要一致</strong>
url生成示例:
明文示例:</p>
<pre><code>{&quot;username&quot;:&quot;xxx&quot;,&quot;password&quot;:&quot;xxx&quot;,&quot;from&quot;:&quot;2&quot;}</code></pre>
<p>密文示例:</p>
<pre><code>21dbe80df90f3be318cb7afda69b4f78</code></pre>
<p>url示例:</p>
<pre><code>1dbe80df</code></pre>
<p>请求表单示例:</p>
<pre><code>{&quot;username&quot;:&quot;xxx&quot;,&quot;password&quot;:&quot;xxx&quot;,&quot;from&quot;:&quot;2&quot;,&quot;url&quot;:&quot;xxxx&quot;}</code></pre>
<p><strong>返回示例</strong></p>
<p>``` {
"code": 0,
"data": {
"id": 3635,
"user_sn": "SYSUSER|b3397882e26ba9e7fb8f01f1af345bde",
"user_name": "zzh",
"team_name": "人工智能客户组",
"team_sn": "SON",
"salt": null,
"passwd": "$2y$10$V1/8xg7Mq5YnEMfMYIef7evQCtIzdB4eW5Q9TvK97OnD/XmVC0Evi",
"blocked": "0",
"bindip": null,
"expired": "2026-08-31",
"amount": 1,
"give_amount": 0,
"priority": null,
"status": null,
"contact": "郑志焕",
"email": "",
"qq": "",
"wangwang": "",
"mobile": null,
"phone": null,
"ext": "888999",
"fax": null,
"fax_ext": null,
"local_phone": null,
"is_staff": null,
"is_active": 2,
"forward_phones": null,
"channel": null,
"display_phone": null,
"secret": null,
"defaultringgroup": null,
"gatewayaddr": null,
"sipname": "zb888999",
"sippwd": null,
"sipproxy": null,
"enabled": null,
"isswitch": null,
"linkext": "1",
"hide_callid": null,
"enable_record": null,
"yd_display_phone": null,
"remember_token": "Sa0woa3azaRE8K0x8IHApgulqsX8PDlAZkVLo6X5Dyepd23AImJhOl35x2ao",
"created_at": "2018-12-04 17:20:58",
"updated_at": "2024-07-09 15:09:04",
"phone_type": null,
"is_order": "1",
"dep_phone": null,
"company": null,
"total_count": 0,
"trunkgroup_id": "0",
"parent_sn": "",
"concurrency": null,
"max_call_count": 14,
"ai_count": 100,
"start_at_one": "08:30:00",
"end_at_one": "12:30:00",
"start_at_two": "13:30:00",
"end_at_two": "21:00:00",
"start_at_three": null,
"end_at_three": null,
"start_at_four": null,
"end_at_four": null,
"project_sn": "projects|1e99759eee92f3f8f0cd3649b4ffda96,projects|4a92f90b5339646b36e9805600820deb,projects|808dfdcb369470376086281d2fdf26a0,projects|5321ee12e21b9467f74a98488e07a8b4,projects|e5b1b8d0f503edab6d5425f91d405a35,projects|648aca1c1ab7f23eab195d02a52052ee,project|a9ade5d7f10b74b66fb32495b66b6a09,project|9ab8f8343f4df4d02787026d03732eeb,projects|840d68a964b8533a63f39cd6f484a4e6,projects|941b663b4f6bef79c0e5f096d173351a,project|0adb8f8cf37e8fb1a785f0605394ce6e,projects|edc0c84159c69dc8a60f360c564d9e80,project|4db886c528383a1120929896d7909d4a,projects|3ae34d77b8c93d8c05036beea1318bf9,project|c4c87e02795564d384c05045235acb90,projects|0b0bb0cc1a75d80ccb681e79fb1ceb19,projects|3a4197ee15668b5b3530d182afc19df2,projects|55581589145ce56d81a161cff3f11781,projects|dc63dfc04d227c34fbe47f38636e4d43,project|1069978be86a36d707af92d016aa18c8,projects|2fa651a14418d1ca536e68b3f81707ba,projects|6468ffd6eac9e3e630f8d991c49ddb34,project|24503865dfcffe8d798a7449eb313feb,projects|061f1b59707b0ae6fc303ced37155141,projects|bfca8e9779e7610d329b9e61a290b75e,projects|d919f1e29c84b2cdd57478894a233bb3,project|9e6f8440cfe587a4d3773eb0012105dc,projects|7c6c95a20d43f1aadfa75b3f3a494343,project|21a55abfb1769a458794773e35e2306b,projects|65f5bd63a1d6765562f0288ce7bec130,projects|2657330a4f82b6828a96a98177ccac21,project|d40c01fc8881579d212076a747ce0bbb,projects|74b4995e21375746bd9362ebf417b2cb,project|18912021113fb33301878d81150ce211,projects|837371e6eaf5a3388ce5c69b25419f3c,projects|c965dfd067ea948e58c324e578dd147e,projects|c965dfd067ea948e58c324e578dd147e,project|b870332c9845901e1d528087c05d212b,projects|d98f8ed376820d8a316954d52a44e50a,projects|c35d5e7d47180eb36b5fae85c9b79be1,projects|61b663bc358c392fbccad2b5c0105c84",
"caller_group": "888999,888999,200050,200053,888998,200049,200088,900002",
"skillgroup_sn": null,
"callin_project_sn": null,
"dial_span": 1000,
"callin_phone": "970085,66866021,970087,886520865,02039723245,61982107,61982108",
"api_user_id": 0,
"api_domain": "",
"api_eid": 0,
"api_account": "",
"api_pwd": "",
"ext_max": "100",
"remark": "",
"api_key": "msWPKWLB",
"api_key_expire": 1720766064,
"open_interface": 1,
"api_auto_cio":"{\"autoSetting\":\"open\",\"api_username\":\"\高\沛\",\"check_lb\":\"13819,13819,13731,,,\"}",
"api_auto_status": null,
"api_id": 0,
"api_verify": "",
"api_check_time": "1593593024",
"caller_number": null,
"open_sms": 1,
"oper_id": 75,
"website": "",
"industry": "小贷行业",
"city": "深圳",
"last_login_time": "2024-07-09 15:09:04",
"need_fix_tel": 0,
"area_code": "",
"callback_url": "<a href="https://adebf652-a052-443a-a337-8ff161ed19de.mock.pstmn.io"">https://adebf652-a052-443a-a337-8ff161ed19de.mock.pstmn.io"</a>;,
"open_callback": "1",
"time_type": 1,
"is_aent_admin": null,
"account_belong": "admin",
"job": "管理员",
"callout_project_sn": null,
"connection_rate_warning": 5,
"warning_stop_call": 0,
"bind_phone": "",
"industry_id": "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,27,28,29,30,31,32,33,34,35,36,37,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,133,135,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,289,292,293,297,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,328,329,330,331,332,333,334,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,406,407,408,409,410,411,412,413,415,416",
"test_project_sn": "project|21a55abfb1769a458794773e35e2306b",
"organization_id": 0,
"analysis_callback_url": "",
"callback_interval_time": 0,
"date_str": "1",
"open_number_check": 0,
"number_check_total": 0,
"used_number_check": 0,
"sdzj_phone": null,
"login_phone": "",
"is_global_hide": 0,
"hm_data_analysis": 1,
"hm_preference_setting": "{\"single_ai_sends_per_day\":\"500\",\"single_ai_hangon_per_day\":\"300\",\"single_seat_intervention_per_day\":\"150\",\"single_seat_intension_per_day\":\"30\"}",
"start_at": "00:00",
"end_at": "23:50",
"ringing_time": 45,
"task_callback_url": "<a href="https://ae81c919-f263-4bbb-afda-b07ad0802d64.mock.pstmn.io"">https://ae81c919-f263-4bbb-afda-b07ad0802d64.mock.pstmn.io"</a>;,
"periods": "[{\"start_at\":\"08:30:00\",\"end_at\":\"22:01:00\"}]",
"min_dial_span": 1000,
"organization_name": null,
"wx_pushed_config": "{\"mode\":1,\"classify\":\"A,B,C,D\",\"interval_min\":1,\"update_time\":1700048960}",
"classification_must_fill": 0,
"open_nlp": 1,
"flash_oper_id": null,
"open_manual_asr": 1,
"manual_call_channel": 100,
"manual_call_channel_lock": 1,
"number_check_type": "empty",
"number_check_total_basic": 0,
"used_number_check_basic": 0,
"is_change_pwd": 1,
"open_auto_add_wechat": 1,
"add_wechat_max": 50,
"first_order_time": null,
"is_searvistor": 0,
"man_machine_seats_count": 80,
"seats_count": 20,
"add_wechat_type": 1,
"is_local": 1,
"total_minutes": 0,
"balance_minutes": 0,
"extend_months": 0
},
"msg": "login success"
}</p>
<pre><code>
**返回参数说明**
|参数名|类型|说明|
|:----- |--- |----- |
|user_name|string|用户名;
|user_sn|string|用户唯一标识符;
|team_name|string|团队名称;
|expired|string|产品过期时间;
|ai_count|string|ai数量;
|caller_group|string|电话组;
|parent_sn|string|父级账号(为空表示主账号)
|api_key|string|请求秘钥
|api_key_expire|string|请求秘钥过期时间(俩小时内有效)
**返回参数code说明**
|参数名|说明|
|:----- |----- |
|0|登录成功
|10001|验证不通过,数据可能被劫持
|20001|数据传输方式不正确
|20002|数据格式错误(少传公共参数)
|20003|该类型客户端不存在
|20004|用户名和密码错误
|20005|api_key验证不通过
|20006|api_key过期
**备注**
- 更多返回错误代码请看首页的错误代码描述</code></pre>