{"id":415,"date":"2026-03-06T13:28:00","date_gmt":"2026-03-06T05:28:00","guid":{"rendered":"https:\/\/www.liaoxinghui.com\/?p=415"},"modified":"2026-03-06T13:28:00","modified_gmt":"2026-03-06T05:28:00","slug":"freeswitch-mod-curl-ecommerce-api-auth-vip-routing","status":"publish","type":"post","link":"https:\/\/www.liaoxinghui.com\/?p=415","title":{"rendered":"\u4f7f\u7528mod_curl\u5b9e\u73b0FreeSWITCH\u4e0e\u7535\u5546\u5ba2\u670d\u4e2d\u5fc3API\u9274\u6743\u96c6\u6210\uff0c\u652f\u6301VIP\u5ba2\u6237\u52a8\u6001\u8def\u7531"},"content":{"rendered":"<h1>\u4f7f\u7528mod_curl\u5b9e\u73b0FreeSWITCH\u4e0e\u7535\u5546\u5ba2\u670d\u4e2d\u5fc3API\u9274\u6743\u96c6\u6210\uff0c\u652f\u6301VIP\u5ba2\u6237\u52a8\u6001\u8def\u7531<\/h1>\n<h2>1. \u4e1a\u52a1\u573a\u666f\u4e0e\u76ee\u6807<\/h2>\n<p>\u7535\u5546\u5ba2\u670d\u4e2d\u5fc3\u5728\u4fc3\u9500\u9ad8\u5cf0\u671f\u9762\u4e34\u5927\u91cf\u6765\u7535\uff0c\u9700\u667a\u80fd\u5206\u914d\uff1aVIP\u5ba2\u6237\uff08\u5982\u5e74\u6d88\u8d39&gt;10\u4e07\u5143\uff09\u5e94\u4f18\u5148\u63a5\u5165\u4e13\u5c5e\u9500\u552e\u5750\u5e2d\uff0c\u666e\u901a\u5ba2\u6237\u63a5\u5165\u5e38\u89c4\u5ba2\u670d\u3002\u4f20\u7edf\u9759\u6001\u8def\u7531\u65e0\u6cd5\u5b9e\u65f6\u8bc6\u522b\u5ba2\u6237\u4ef7\u503c\u3002\u76ee\u6807\uff1a\u901a\u8fc7mod_curl\u8c03\u7528CRM API\uff0c\u6839\u636e\u6765\u7535\u53f7\u7801\u5b9e\u65f6\u67e5\u8be2\u5ba2\u6237\u7b49\u7ea7\uff08VIP\/\u666e\u901a\uff09\uff0c\u52a8\u6001\u8def\u7531\u5230\u4e0d\u540c\u5750\u5e2d\u7ec4\uff08vip_sales\/support\uff09\uff0c\u5e76\u64ad\u653e\u4e2a\u6027\u5316\u6b22\u8fce\u8bcd\uff0c\u63d0\u5347VIP\u5ba2\u6237\u6ee1\u610f\u5ea6\u548c\u9500\u552e\u8f6c\u5316\u3002<\/p>\n<h2>2. \u73af\u5883\u51c6\u5907\uff08uv + \u4f9d\u8d56\uff09<\/h2>\n<p>\u672c\u4efb\u52a1\u7c7b\u578b\u4e3a\u7cfb\u7edf\u96c6\u6210\u4e0e\u914d\u7f6e\u3002\u9700\u5b89\u88c5FreeSWITCH\uff08\u7248\u672c1.10+\uff09\u5e76\u542f\u7528mod_curl\u6a21\u5757\uff0c\u5916\u90e8API\u670d\u52a1\u4f7f\u7528Python Flask\u6846\u67b6\u6a21\u62df\u3002<\/p>\n<ul>\n<li>\u5b89\u88c5FreeSWITCH\uff1a\u53c2\u8003\u5b98\u65b9\u6587\u6863\uff08\u5982<code>apt-get install freeswitch<\/code>\uff09\u3002<\/li>\n<li>\u68c0\u67e5mod_curl\uff1a\u5728FreeSWITCH\u63a7\u5236\u53f0\u6267\u884c<code>load mod_curl<\/code>\uff0c\u786e\u8ba4\u6a21\u5757\u52a0\u8f7d\u6210\u529f\u3002<\/li>\n<li>\u5916\u90e8API\u73af\u5883\uff1a\u4f7f\u7528uv\u521b\u5efaPython\u865a\u62df\u73af\u5883\u5e76\u5b89\u88c5\u4f9d\u8d56\u3002\n<pre><code class=\"lang-bash language-bash bash\">uv venv venv\nsource venv\/bin\/activate\nuv add flask requests<\/code><\/pre><\/li>\n<\/ul>\n<h2>3. \u6570\u636e\u8bf4\u660e\uff08\u771f\u5b9e\u6570\u636e\u53e3\u5f84\u6216\u6a21\u62df\u6570\u636e\u751f\u6210\u903b\u8f91\uff09<\/h2>\n<p>\u6a21\u62df\u7535\u5546CRM\u6570\u636e\uff1aAPI\u6839\u636e\u6765\u7535\u53f7\u7801\u67e5\u8be2\u5ba2\u6237\u7b49\u7ea7\u3002\u6570\u636e\u751f\u6210\u903b\u8f91\uff1a\u6765\u7535\u53f7\u7801\u4ee5<code>138<\/code>\u5f00\u5934\u6a21\u62dfVIP\u5ba2\u6237\uff08\u5e74\u6d88\u8d39&gt;10\u4e07\uff09\uff0c\u8fd4\u56de<code>{&quot;customer_level&quot;: &quot;VIP&quot;, &quot;agent_group&quot;: &quot;vip_sales&quot;, &quot;greeting&quot;: &quot;\u5c0a\u8d35\u7684VIP\u5ba2\u6237\uff0c\u4e3a\u60a8\u8f6c\u63a5\u4e13\u5c5e\u987e\u95ee&quot;}<\/code>\uff1b\u5176\u4ed6\u53f7\u7801\u6a21\u62df\u666e\u901a\u5ba2\u6237\uff0c\u8fd4\u56de<code>{&quot;customer_level&quot;: &quot;normal&quot;, &quot;agent_group&quot;: &quot;support&quot;, &quot;greeting&quot;: &quot;\u60a8\u597d\uff0c\u5ba2\u670d\u4ee3\u8868\u4e3a\u60a8\u670d\u52a1&quot;}<\/code>\u3002\u771f\u5b9e\u4e1a\u52a1\u4e2d\uff0cAPI\u5e94\u8fde\u63a5\u771f\u5b9eCRM\u6570\u636e\u5e93\uff0c\u67e5\u8be2\u5ba2\u6237\u6d88\u8d39\u8bb0\u5f55\u3002<\/p>\n<h2>4. \u8bad\u7ec3\/\u5b9e\u73b0\u6b65\u9aa4\uff08\u5b8c\u6574\u4ee3\u7801\uff09<\/h2>\n<h3>\u6b65\u9aa41\uff1a\u914d\u7f6eFreeSWITCH\u7684mod_curl<\/h3>\n<p>\u7f16\u8f91<code>\/etc\/freeswitch\/autoload_configs\/curl.conf.xml<\/code>\uff0c\u8bbe\u7f6e\u8d85\u65f6\u548c\u91cd\u8bd5\u53c2\u6570\u3002<\/p>\n<pre><code class=\"lang-xml language-xml xml\">&lt;configuration name=&quot;curl.conf&quot; description=&quot;cURL Configuration&quot;&gt;\n\n&lt;settings&gt;\n    &lt;param name=&quot;enable&quot; value=&quot;true&quot;\/&gt;\n    &lt;param name=&quot;timeout&quot; value=&quot;3&quot;\/&gt;\n    &lt;param name=&quot;retries&quot; value=&quot;2&quot;\/&gt;\n    &lt;param name=&quot;retry-delay&quot; value=&quot;1000&quot;\/&gt;\n  &lt;\/settings&gt;\n&lt;\/configuration&gt;<\/code><\/pre>\n<h3>\u6b65\u9aa42\uff1a\u7f16\u5199\u7535\u5546CRM API\u670d\u52a1\uff08Flask\u5e94\u7528\uff09<\/h3>\n<p>\u521b\u5efa<code>ecommerce_api.py<\/code>\uff0c\u5b9e\u73b0\u9274\u6743\u548c\u5ba2\u6237\u7b49\u7ea7\u67e5\u8be2\u3002<\/p>\n<pre><code class=\"lang-python language-python python\">from flask import Flask, request, jsonify\nimport time\nimport logging\n\napp = Flask(__name__)\nAPI_KEY = &quot;ecommerce_secret_2024&quot;  # \u5b9e\u9645\u5e94\u4f7f\u7528\u73af\u5883\u53d8\u91cf\u5982os.getenv(&#039;API_KEY&#039;)\n\n@app.route(&#039;\/customer\/route&#039;, methods=[&#039;POST&#039;])\ndef route_call():\n    # \u9274\u6743\uff1a\u68c0\u67e5API\u5bc6\u94a5\n    auth_key = request.headers.get(&#039;X-API-Key&#039;)\n    if auth_key != API_KEY:\n        app.logger.warning(f&quot;Unauthorized access attempt with key: {auth_key}&quot;)\n        return jsonify({&quot;error&quot;: &quot;Unauthorized&quot;}), 401\n\n    # \u83b7\u53d6\u6765\u7535\u53f7\u7801\n    data = request.json\n    caller_id = data.get(&#039;caller_id&#039;, &#039;&#039;)\n    if not caller_id:\n        return jsonify({&quot;error&quot;: &quot;Missing caller_id&quot;}), 400\n\n    # \u6a21\u62df\u7535\u5546CRM\u67e5\u8be2\uff1aVIP\u5ba2\u6237\u8bc6\u522b\n    # \u771f\u5b9e\u573a\u666f\uff1a\u6b64\u5904\u5e94\u67e5\u8be2\u6570\u636e\u5e93\uff0c\u4f8b\u5982SELECT customer_level FROM customers WHERE phone=caller_id\n    if caller_id.startswith(&#039;138&#039;):\n        # VIP\u5ba2\u6237\uff0c\u6a21\u62df\u67e5\u8be2\u8017\u65f6200ms\n        time.sleep(0.2)\n        response = {\n            &quot;customer_level&quot;: &quot;VIP&quot;,\n            &quot;agent_group&quot;: &quot;vip_sales&quot;,\n            &quot;greeting&quot;: &quot;\u5c0a\u8d35\u7684VIP\u5ba2\u6237\uff0c\u4e3a\u60a8\u8f6c\u63a5\u4e13\u5c5e\u987e\u95ee&quot;\n        }\n    else:\n        # \u666e\u901a\u5ba2\u6237\uff0c\u6a21\u62df\u67e5\u8be2\u8017\u65f6100ms\n        time.sleep(0.1)\n        response = {\n            &quot;customer_level&quot;: &quot;normal&quot;,\n            &quot;agent_group&quot;: &quot;support&quot;,\n            &quot;greeting&quot;: &quot;\u60a8\u597d\uff0c\u5ba2\u670d\u4ee3\u8868\u4e3a\u60a8\u670d\u52a1&quot;\n        }\n\n    app.logger.info(f&quot;Call from {caller_id} routed to {response[&#039;agent_group&#039;]}&quot;)\n    return jsonify(response), 200\n\nif __name__ == &#039;__main__&#039;:\n    logging.basicConfig(level=logging.INFO)\n    app.run(host=&#039;0.0.0.0&#039;, port=5000, debug=False)<\/code><\/pre>\n<h3>\u6b65\u9aa43\uff1a\u914d\u7f6eFreeSWITCH\u62e8\u53f7\u8ba1\u5212<\/h3>\n<p>\u7f16\u8f91<code>\/etc\/freeswitch\/dialplan\/default.xml<\/code>\uff0c\u6dfb\u52a0\u52a8\u6001\u8def\u7531\u903b\u8f91\uff0c\u5305\u542b\u8d85\u65f6\u56de\u9000\u673a\u5236\u3002<\/p>\n<pre><code class=\"lang-xml language-xml xml\">&lt;extension name=&quot;ecommerce_dynamic_routing&quot;&gt;\n  &lt;condition field=&quot;destination_number&quot; expression=&quot;^\\d+$&quot;&gt;\n    &lt;!-- \u8c03\u7528CRM API\uff0c\u8d85\u65f63\u79d2\uff0c\u91cd\u8bd52\u6b21 --&gt;\n    &lt;action application=&quot;curl&quot; \n            data=&quot;http:\/\/localhost:5000\/customer\/route post application\/json {\\&quot;caller_id\\&quot;: ${caller_id_number}} X-API-Key:ecommerce_secret_2024&quot;\/&gt;\n    &lt;action application=&quot;set&quot; \n            data=&quot;api_response=${curl_response_data}&quot;\/&gt;\n    &lt;action application=&quot;log&quot; \n            data=&quot;INFO Raw API Response: ${api_response}&quot;\/&gt;\n\n    &lt;!-- \u89e3\u6790API\u54cd\u5e94\uff0c\u5982\u679c\u5931\u8d25\u5219\u4f7f\u7528\u9ed8\u8ba4\u8def\u7531 --&gt;\n    &lt;action application=&quot;set&quot; \n            data=&quot;agent_group=${regex(${api_response} |\\&quot;agent_group\\&quot;:\\&quot;([^\\&quot;]+)\\&quot;)}&quot;\/&gt;\n    &lt;action application=&quot;set&quot; \n            data=&quot;greeting=${regex(${api_response} |\\&quot;greeting\\&quot;:\\&quot;([^\\&quot;]+)\\&quot;)}&quot;\/&gt;\n\n    &lt;!-- \u68c0\u67e5\u89e3\u6790\u7ed3\u679c\uff0c\u5982\u679c\u4e3a\u7a7a\u5219\u4f7f\u7528\u9ed8\u8ba4\u503c --&gt;\n    &lt;action application=&quot;execute_extension&quot; \n            data=&quot;check_api_result&quot;\/&gt;\n  &lt;\/condition&gt;\n&lt;\/extension&gt;\n\n&lt;extension name=&quot;check_api_result&quot;&gt;\n  &lt;condition field=&quot;${agent_group}&quot; expression=&quot;^$&quot;&gt;\n    &lt;action application=&quot;log&quot; \n            data=&quot;WARNING API call failed, using default routing&quot;\/&gt;\n    &lt;action application=&quot;set&quot; \n            data=&quot;agent_group=support&quot;\/&gt;\n    &lt;action application=&quot;set&quot; \n            data=&quot;greeting=\u60a8\u597d\uff0c\u5ba2\u670d\u4ee3\u8868\u4e3a\u60a8\u670d\u52a1&quot;\/&gt;\n  &lt;\/condition&gt;\n\n&lt;condition&gt;\n    &lt;action application=&quot;answer&quot;\/&gt;\n    &lt;action application=&quot;playback&quot; \n            data=&quot;say:${greeting}&quot;\/&gt;\n    &lt;action application=&quot;bridge&quot; \n            data=&quot;sofia\/internal\/1000@${agent_group}.example.com&quot;\/&gt;\n  &lt;\/condition&gt;\n&lt;\/extension&gt;<\/code><\/pre>\n<h2>5. \u8c03\u7528\u65b9\u5f0f<\/h2>\n<ul>\n<li>\n<p>\u5355\u6761\u793a\u4f8b\uff1a\u5728FreeSWITCH\u63a7\u5236\u53f0\u6267\u884c\u547d\u4ee4\u6d4b\u8bd5VIP\u5ba2\u6237\u8def\u7531\u3002<\/p>\n<pre><code class=\"lang-bash language-bash bash\"># \u5728FreeSWITCH CLI\u4e2d\u6267\u884c\uff0c\u6a21\u62dfVIP\u6765\u7535\noriginate sofia\/gateway\/your_gateway\/13800138000 &amp;bridge\n# \u9884\u671f\uff1a\u8c03\u7528API\uff0c\u8def\u7531\u5230vip_sales\u5750\u5e2d\u7ec4\uff0c\u64ad\u653eVIP\u6b22\u8fce\u8bcd<\/code><\/pre>\n<\/li>\n<li>\n<p>\u79bb\u7ebf\u6279\u91cf\uff1a\u4f7f\u7528ESL\u811a\u672c\u6a21\u62df100\u4e2a\u6765\u7535\u53f7\u7801\uff0c\u6d4b\u8bd5\u8def\u7531\u51c6\u786e\u6027\u548c\u6027\u80fd\u3002\u521b\u5efa<code>batch_test.py<\/code>\u3002<\/p>\n<pre><code class=\"lang-python language-python python\">\nimport ESL\nimport time\nimport random<\/code><\/pre>\n<\/li>\n<\/ul>\n<h1>\u8fde\u63a5FreeSWITCH ESL<\/h1>\n<p>con = ESL.ESLconnection(&#8220;localhost&#8221;, &#8220;8021&#8221;, &#8220;ClueCon&#8221;)\nif not con.connected():\nprint(&#8220;Failed to connect to FreeSWITCH&#8221;)\nexit(1)<\/p>\n<h1>\u751f\u6210\u6d4b\u8bd5\u53f7\u7801\uff1a50\u4e2aVIP\uff08138\u5f00\u5934\uff09\uff0c50\u4e2a\u666e\u901a<\/h1>\n<p>test<em>numbers = [f&#8221;138{random.randint(10000000, 99999999):08d}&#8221; for <\/em> in range(50)]\ntest<em>numbers += [f&#8221;139{random.randint(10000000, 99999999):08d}&#8221; for <\/em> in range(50)]<\/p>\n<p>print(f&#8221;Starting batch test for {len(test_numbers)} calls&#8230;&#8221;)\nsuccess_count = 0\nfor i, number in enumerate(test_numbers, 1):<\/p>\n<h1>\u53d1\u8d77\u547c\u53eb<\/h1>\n<pre><code>cmd = f&quot;originate sofia\/gateway\/test_gw\/{number} &amp;bridge&quot;\nresult = con.api(cmd)\n\nif &quot;+OK&quot; in result.getBody():\n    success_count += 1\n    print(f&quot;Call {i}: {number} initiated successfully&quot;)\nelse:\n    print(f&quot;Call {i}: {number} failed - {result.getBody()}&quot;)\n\n# \u95f4\u9694100ms\u907f\u514d\u8fc7\u8f7d\ntime.sleep(0.1)<\/code><\/pre>\n<p>print(f&#8221;Batch test completed. Success rate: {success_count}\/{len(test_numbers)} ({success_count\/len(test_numbers)*100:.1f}%)&#8221;)\ncon.disconnect()<\/p>\n<pre><code>\n\n## 6. \u6307\u6807\u8bf4\u660e\n- **FreeSWITCH**\uff1a\u5f00\u6e90\u7535\u8bdd\u8f6f\u4ea4\u6362\u5e73\u53f0\uff0c\u5904\u7406\u8bed\u97f3\u901a\u8bdd\u548c\u8def\u7531\uff0c\u76f8\u5f53\u4e8e\u7535\u8bdd\u7cfb\u7edf\u7684&ldquo;\u5927\u8111&rdquo;\u3002\n- **mod_curl**\uff1aFreeSWITCH\u6a21\u5757\uff0c\u5141\u8bb8\u901a\u8fc7HTTP\u8c03\u7528\u5916\u90e8API\uff0c\u7c7b\u4f3c\u6d4f\u89c8\u5668\u8bbf\u95ee\u7f51\u9875\u4f46\u7528\u4e8e\u7535\u8bdd\u7cfb\u7edf\u3002\n- **API\u9274\u6743**\uff1a\u9a8c\u8bc1\u8bf7\u6c42\u662f\u5426\u5408\u6cd5\uff0c\u672c\u9879\u76ee\u4e2d\u901a\u8fc7API\u5bc6\u94a5\uff08X-API-Key\uff09\u5b9e\u73b0\uff0c\u9632\u6b62\u672a\u6388\u6743\u8bbf\u95ee\u3002\n- **\u52a8\u6001\u8def\u7531**\uff1a\u6839\u636e\u5b9e\u65f6\u6570\u636e\uff08\u5982\u6765\u7535\u53f7\u7801\uff09\u51b3\u5b9a\u901a\u8bdd\u53bb\u5411\uff0c\u6bd4\u5982VIP\u5ba2\u6237\u8f6c\u9500\u552e\uff0c\u666e\u901a\u5ba2\u6237\u8f6c\u5ba2\u670d\u3002\n- **\u62e8\u53f7\u8ba1\u5212**\uff1aFreeSWITCH\u4e2d\u5b9a\u4e49\u901a\u8bdd\u5904\u7406\u89c4\u5219\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u544a\u8bc9\u7cfb\u7edf\u5982\u4f55\u54cd\u5e94\u6765\u7535\u3002\n- **CRM\u7cfb\u7edf**\uff1a\u5ba2\u6237\u5173\u7cfb\u7ba1\u7406\u7cfb\u7edf\uff0c\u5b58\u50a8\u5ba2\u6237\u4fe1\u606f\u5982\u8d2d\u4e70\u8bb0\u5f55\u3001\u7b49\u7ea7\uff0c\u7528\u4e8e\u8def\u7531\u51b3\u7b56\u3002\n- **\u5750\u5e2d\u7ec4**\uff1a\u5ba2\u670d\u6216\u9500\u552e\u56e2\u961f\u7684\u5206\u7ec4\uff0c\u5982vip_sales\u7ec4\u4e13\u95e8\u670d\u52a1VIP\u5ba2\u6237\u3002\n- **API\u8c03\u7528\u6210\u529f\u7387**\uff1aFreeSWITCH\u6210\u529f\u8c03\u7528API\u5e76\u83b7\u5f97\u6709\u6548\u54cd\u5e94\u7684\u6bd4\u4f8b\uff0c\u4f8b\u5982100\u6b21\u8c03\u7528\u4e2d95\u6b21\u6210\u529f\uff0c\u6210\u529f\u7387\u4e3a95%\u3002\n- **\u5e73\u5747\u54cd\u5e94\u65f6\u95f4**\uff1a\u4eceFreeSWITCH\u53d1\u9001API\u8bf7\u6c42\u5230\u6536\u5230\u56de\u590d\u7684\u5e73\u5747\u8017\u65f6\uff0c\u5f71\u54cd\u901a\u8bdd\u5ef6\u8fdf\uff0c\u76ee\u6807\u5c0f\u4e8e500\u6beb\u79d2\u3002\n- **\u901a\u8bdd\u63a5\u901a\u7387**\uff1a\u6210\u529f\u63a5\u901a\u7684\u901a\u8bdd\u5360\u603b\u901a\u8bdd\u6570\u7684\u6bd4\u4f8b\uff0c\u53cd\u6620\u7cfb\u7edf\u6574\u4f53\u7a33\u5b9a\u6027\uff0c\u76ee\u6807&gt;98%\u3002\n- **ESL**\uff1aEvent Socket Library\uff0cFreeSWITCH\u7684\u4e8b\u4ef6\u63a5\u53e3\uff0c\u5141\u8bb8\u5916\u90e8\u7a0b\u5e8f\u63a7\u5236\u901a\u8bdd\u3002\n\n## 7. \u4e0a\u7ebf\u540e\u8bc4\u4f30\uff08\u8fd0\u884c\u6307\u6807\uff0c\u8bc4\u4f30\u65b9\u6cd5\uff09\n- **API\u8c03\u7528\u6210\u529f\u7387**\uff1a\u76ee\u6807&gt;99%\u3002\u8bc4\u4f30\u65b9\u6cd5\uff1a\u76d1\u63a7FreeSWITCH\u65e5\u5fd7\uff0c\u7edf\u8ba1`curl`\u547d\u4ee4\u7684\u6210\u529f\u4e0e\u5931\u8d25\u6b21\u6570\u3002\u5b9e\u65bd\u6b65\u9aa4\uff1a\u90e8\u7f72\u65e5\u5fd7\u6536\u96c6\u811a\u672c\uff0c\u89e3\u6790\u65e5\u5fd7\u4e2d\u7684`curl_response_data`\u5b57\u6bb5\uff0c\u8ba1\u7b97\u6210\u529f\u7387\u3002\n- **\u5e73\u5747\u54cd\u5e94\u65f6\u95f4**\uff1a\u76ee\u6807&lt;500ms\u3002\u8bc4\u4f30\u65b9\u6cd5\uff1a\u6d4b\u91cfAPI\u8017\u65f6\uff0c\u4eceFreeSWITCH\u65e5\u5fd7\u63d0\u53d6\u65f6\u95f4\u6233\u3002\u5b9e\u65bd\u6b65\u9aa4\uff1a\u5728\u62e8\u53f7\u8ba1\u5212\u4e2d\u6dfb\u52a0`&lt;action application=&quot;log&quot; data=&quot;INFO API time: ${curl_response_time}&quot;\/&gt;`\uff0c\u4f7f\u7528\u811a\u672c\u8ba1\u7b97\u5e73\u5747\u503c\u3002\n- **\u901a\u8bdd\u63a5\u901a\u7387**\uff1a\u76ee\u6807&gt;98%\u3002\u8bc4\u4f30\u65b9\u6cd5\uff1a\u5206\u6790CDR\uff08\u547c\u53eb\u8be6\u7ec6\u8bb0\u5f55\uff09\u6587\u4ef6\u3002\u5b9e\u65bd\u6b65\u9aa4\uff1a\u914d\u7f6eCDR\u5b58\u50a8\uff0c\u7f16\u5199Python\u811a\u672c\u89e3\u6790CDR\uff0c\u7edf\u8ba1\u72b6\u6001\u4e3a`ANSWERED`\u7684\u6bd4\u4f8b\u3002\n- **\u76d1\u63a7\u4eea\u8868\u677f\u914d\u7f6e**\uff1a\u4f7f\u7528Prometheus+Grafana\u5b9e\u65f6\u76d1\u63a7\u3002\u5b9e\u65bd\u6b65\u9aa4\uff1a\u5728API\u670d\u52a1\u4e2d\u6dfb\u52a0\/metrics\u7aef\u70b9\u66b4\u9732\u6307\u6807\uff08\u5982\u8bf7\u6c42\u6570\u3001\u5ef6\u8fdf\uff09\uff0c\u914d\u7f6ePrometheus\u6293\u53d6\uff0cGrafana\u5c55\u793a\u4eea\u8868\u677f\u3002\n\n## 8. \u5e38\u89c1\u5751\u4e0e\u6392\u67e5\n- **API\u54cd\u5e94\u8d85\u65f6\u5bfc\u81f4\u901a\u8bdd\u5931\u8d25**\uff1a\u73b0\u8c61\uff1a\u901a\u8bdd\u5361\u987f\u6216\u76f4\u63a5\u6302\u65ad\u3002\u6392\u67e5\uff1a\u68c0\u67e5API\u670d\u52a1\u5668\u8d1f\u8f7d\u548c\u7f51\u7edc\u5ef6\u8fdf\u3002\u5b9e\u9645\u64cd\u4f5c\uff1a\u5728`curl.conf.xml`\u4e2d\u8c03\u6574\u8d85\u65f6\u548c\u91cd\u8bd5\u53c2\u6570\uff0c\u5982\u8bbe\u7f6e`&lt;param name=&quot;timeout&quot; value=&quot;5&quot;\/&gt;`\u548c`&lt;param name=&quot;retries&quot; value=&quot;3&quot;\/&gt;`\uff1b\u5728\u62e8\u53f7\u8ba1\u5212\u4e2d\u6dfb\u52a0\u8d85\u65f6\u56de\u9000\u903b\u8f91\uff08\u5982\u672c\u6587\u6b65\u9aa43\u7684`check_api_result`\u6269\u5c55\uff09\u3002\n- **\u9274\u6743\u903b\u8f91\u6f0f\u6d1e\u5f15\u53d1\u5b89\u5168\u98ce\u9669**\uff1a\u73b0\u8c61\uff1aAPI\u8fd4\u56de401\u9519\u8bef\u3002\u6392\u67e5\uff1a\u786e\u8ba4API\u5bc6\u94a5\u5728FreeSWITCH\u914d\u7f6e\u4e2d\u6b63\u786e\uff0c\u4e14\u4f20\u8f93\u52a0\u5bc6\u3002\u5b9e\u9645\u64cd\u4f5c\uff1a\u4f7f\u7528\u73af\u5883\u53d8\u91cf\u5b58\u50a8\u5bc6\u94a5\uff0c\u907f\u514d\u786c\u7f16\u7801\uff1b\u5728FreeSWITCH CLI\u6d4b\u8bd5\uff1a`curl http:\/\/localhost:5000\/customer\/route -H &quot;X-API-Key:ecommerce_secret_2024&quot;`\u9a8c\u8bc1\u8fde\u901a\u6027\u3002\n- **\u914d\u7f6e\u9519\u8bef\u5bfc\u81f4\u8def\u7531\u6df7\u4e71**\uff1a\u73b0\u8c61\uff1a\u5ba2\u6237\u88ab\u9519\u8bef\u8def\u7531\uff08\u5982VIP\u8f6c\u5230\u666e\u901a\u5750\u5e2d\uff09\u3002\u6392\u67e5\uff1a\u68c0\u67e5\u62e8\u53f7\u8ba1\u5212\u4e2d\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u662f\u5426\u5339\u914dJSON\u54cd\u5e94\u3002\u5b9e\u9645\u64cd\u4f5c\uff1a\u5728\u62e8\u53f7\u8ba1\u5212\u4e2d\u6dfb\u52a0\u8be6\u7ec6\u65e5\u5fd7\u8f93\u51fa`&lt;action application=&quot;log&quot; data=&quot;INFO Parsed agent_group: ${agent_group}&quot;\/&gt;`\uff0c\u5bf9\u6bd4API\u539f\u59cb\u54cd\u5e94\u3002\n- **\u5916\u90e8\u7cfb\u7edf\u6545\u969c\u5f71\u54cd\u901a\u8bdd**\uff1a\u73b0\u8c61\uff1aAPI\u670d\u52a1\u5b95\u673a\uff0c\u6240\u6709\u901a\u8bdd\u5931\u8d25\u3002\u6392\u67e5\uff1a\u76d1\u63a7API\u5065\u5eb7\u72b6\u6001\u3002\u5b9e\u9645\u64cd\u4f5c\uff1a\u5b9e\u73b0\u5fc3\u8df3\u68c0\u6d4b\uff0c\u4f8b\u5982FreeSWITCH\u5b9a\u65f6\u8c03\u7528API\u5065\u5eb7\u68c0\u67e5\u7aef\u70b9\uff1b\u90e8\u7f72\u5907\u7528API\u670d\u52a1\u5668\uff0c\u5728\u62e8\u53f7\u8ba1\u5212\u4e2d\u4f7f\u7528\u6545\u969c\u8f6c\u79fb\u903b\u8f91\u3002<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u9488\u5bf9\u7535\u5546\u5ba2\u670d\u4e2d\u5fc3\u573a\u666f\uff0c\u901a\u8fc7mod_curl\u6a21\u5757\u5c06FreeSWITCH\u4e0e\u5916\u90e8CRM API\u96c6\u6210\uff0c\u5b9e\u73b0\u57fa\u4e8e\u6765\u7535\u53f7\u7801\u7684\u9274\u6743\u548c\u52a8\u6001\u8def\u7531\uff0c\u652f\u6301\u9ad8\u5cf0\u671fVIP\u5ba2\u6237\u4f18\u5148\u63a5\u5165\u9500\u552e\u5750\u5e2d\uff0c\u63d0\u5347\u5ba2\u6237\u4f53\u9a8c\u548c\u8f6c\u5316\u7387\u3002<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[138],"class_list":["post-415","post","type-post","status-publish","format-standard","hentry","category-freeswitch","tag-freeswitch"],"views":134,"_links":{"self":[{"href":"https:\/\/www.liaoxinghui.com\/index.php?rest_route=\/wp\/v2\/posts\/415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.liaoxinghui.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.liaoxinghui.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.liaoxinghui.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.liaoxinghui.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=415"}],"version-history":[{"count":1,"href":"https:\/\/www.liaoxinghui.com\/index.php?rest_route=\/wp\/v2\/posts\/415\/revisions"}],"predecessor-version":[{"id":447,"href":"https:\/\/www.liaoxinghui.com\/index.php?rest_route=\/wp\/v2\/posts\/415\/revisions\/447"}],"wp:attachment":[{"href":"https:\/\/www.liaoxinghui.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=415"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.liaoxinghui.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=415"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.liaoxinghui.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}