{"id":8770,"date":"2023-05-29T20:53:24","date_gmt":"2023-05-29T12:53:24","guid":{"rendered":"\/?p=8770"},"modified":"2023-05-29T21:02:26","modified_gmt":"2023-05-29T13:02:26","slug":"%e5%be%ae%e4%bf%a1%e6%9c%ba%e5%99%a8%e4%ba%ba-%e5%8f%af%e7%88%b1%e7%8c%abpython","status":"publish","type":"post","link":"\/?p=8770","title":{"rendered":"\u5fae\u4fe1\u673a\u5668\u4eba\u2014\u2014\u53ef\u7231\u732b+python"},"content":{"rendered":"<h2>\u4e00\u3001\u5fae\u4fe1\u673a\u5668\u4eba\u6982\u8ff0<\/h2>\n<h3>1.\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba<\/h3>\n<p>\u521a\u5f00\u59cb\u60f3\u7814\u7a76\u4e0b\u5fae\u4fe1\u673a\u5668\u4eba\uff0c\u4e86\u89e3\u5230\u4f01\u4e1a\u5fae\u4fe1\u7c7b\u4f3c\u4e8e\u9489\u9489\uff0c\u5f00\u653e\u4e86api\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u8fdb\u884c\u8c03\u7528\uff0c\u4ee5\u4fbf\u4e8e\u5b8c\u6210\u5404\u79cd\u64cd\u4f5c\uff0c\u4f46\u662f\u4f01\u4e1a\u5fae\u4fe1\u6709\u4e24\u4e2a\u81f4\u547d\u7f3a\u70b9\uff0c\u8ba9\u6211\u4e0d\u5f97\u4e0d\u653e\u5f03\uff1a<\/p>\n<p><strong>\u7f3a\u70b91<\/strong>\uff1a\u65e0\u6cd5\u76d1\u542c\u6d88\u606f<\/p>\n<p>\u9489\u9489\u7ed9\u51fa\u4e86\u63a5\u53e3\uff0c\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u8f6e\u8be2\u8bf7\u6c42\uff0c\u4ee5\u83b7\u5f97\u6d88\u606f\uff0c\u4f01\u4e1a\u5fae\u4fe1\u561b... \u53ea\u80fd\u53d1\uff0c\u4e0d\u80fd\u6536\u3002<\/p>\n<p>\u8fd9\u73a9\u610f\u592a\u4f24\u4e86\uff0c\u7b49\u4e8e\u8bf4\u5fae\u4fe1\u673a\u5668\u4eba\u7eaf\u5c5e\u7fa4\u53d1\uff0c\u6839\u672c\u4e0d\u80fd\u5bf9\u4efb\u4f55\u6d88\u606f\u4f5c\u51fa\u54cd\u5e94\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u57fa\u672c\u7b49\u4e8e\u5e9f\u7269\u3002<\/p>\n<p><strong>\u7f3a\u70b92<\/strong>\uff1a\u4ec5\u9650\u4e8e\u4f01\u4e1a\u5fae\u4fe1\u7fa4<\/p>\n<p>\u8fd9\u4e2a\u7fa4\u8fd8\u4e0d\u662f\u90a3\u79cd\u666e\u901a\u8d26\u53f7\u90fd\u53ef\u4ee5\u52a0\u5165\u7684\u90a3\u79cd\uff0c\u8fd8\u662f\u4ec5\u9650\u4e8e\u4f01\u4e1a\u5fae\u4fe1\u7fa4\u804a\u4e2d\u6dfb\u52a0\u5b98\u65b9\u673a\u5668\u4eba\uff0c\u89e3\u91ca\u4e00\u4e0b\uff0c\u5c31\u662f\u53ea\u80fd\u4e0b\u8f7d\u4f01\u4e1a\u5fae\u4fe1APP\uff0c\u5728\u4f01\u4e1a\u5fae\u4fe1APP\u91cc\u5efa\u7acb\u7684\u7fa4\u804a\uff0c\u624d\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u5fae\u4fe1\u673a\u5668\u4eba\u3002<\/p>\n<p>\u9274\u4e8e\u4ee5\u4e0a\u4e24\u70b9\u6765\u770b\uff0c\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba\u7684\u5e94\u7528\u9762\u6781\u5176\u7a84\uff0c\u4e00\u822c\u4eba\u7528\u8fd9\u4e2a\u6839\u672c\u6ca1\u4ec0\u4e48\u7403\u7528\uff0c\u5f00\u53d1\u8fd9\u4e2a\u7eaf\u5c5e\u6d6a\u8d39\u4e86\u6211\u7684\u5b9d\u8d35\u65f6\u95f4\u3002<\/p>\n<p><strong>\u5b98\u65b9\u6587\u6863\uff1a<\/strong><\/p>\n<p><a href=\"https:\/\/open.work.weixin.qq.com\/help2\/pc\/14931\">\u5982\u4f55\u8bbe\u7f6e\u7fa4\u673a\u5668\u4eba -\u5e2e\u52a9\u4e2d\u5fc3-\u4f01\u4e1a\u5fae\u4fe1 (qq.com)<\/a><\/p>\n<p><a href=\"https:\/\/developer.work.weixin.qq.com\/document\/path\/91770\">\u7fa4\u673a\u5668\u4eba\u914d\u7f6e\u8bf4\u660e - \u63a5\u53e3\u6587\u6863 - \u4f01\u4e1a\u5fae\u4fe1\u5f00\u53d1\u8005\u4e2d\u5fc3 (qq.com)<\/a><\/p>\n<p>python\u793a\u4f8b\uff1a<\/p>\n<pre><code class=\"language-python\">&quot;&quot;&quot;\n\u4e0a\u4f20\u6587\u4ef6\u529f\u80fd\n&quot;&quot;&quot;\nimport json\nimport requests\nimport os\n\ndef send_message(media_id):\n    headers = {\n        &quot;Content-Type&quot;: &quot;application\/json&quot;\n    }\n    url = &quot;https:\/\/qyapi.weixin.qq.com\/cgi-bin\/webhook\/send?key=7d1e7b25-fa81-4524-bf3a-5b9030bb9068&quot;\n    data = {\n        &quot;msgtype&quot;: &quot;file&quot;,\n        &quot;file&quot;: {\n            &quot;media_id&quot;: media_id\n        }\n    }\n    response = requests.post(url, headers=headers, data=json.dumps(data))\n\n    print(response.text)\n    print(response)\ndef get_media_id():\n    file_path = &quot;\u5085\u60c5.txt&quot;\n    filelength = os.path.getsize(file_path)\n    headers = {\n        # &quot;Content-Type&quot;: &quot;application\/json&quot;,\n        # &quot;Content-Length&quot;: str(filelength),\n        &quot;Content-Disposition&quot;: f&#039;form-data; name=&quot;media&quot;;filename=&quot;{file_path}&quot;; filelength={filelength}&#039;,\n        &quot;Content-Type&quot;: &quot;application\/octet-stream&quot;\n\n    }\n    f = open(file_path, &#039;rb&#039;)\n    url = &quot;https:\/\/qyapi.weixin.qq.com\/cgi-bin\/webhook\/upload_media?key=7d1e7b25-fa81-4524-bf3a-5b9030bb9068&amp;type=file&quot;\n    files = {&quot;file&quot;: f}\n    response = requests.post(url,\n                             # headers=headers,\n                             files=files)\n    print(response.text)\n    print(response)\n    return response.json().get(&#039;media_id&#039;)\nif __name__ == &#039;__main__&#039;:\n    media_id = get_media_id()\n    send_message(media_id)\n<\/code><\/pre>\n<h3>2.\u666e\u901a\u5fae\u4fe1\u673a\u5668\u4eba<\/h3>\n<p><strong><em>\u666e\u901a\u5fae\u4fe1\u662f\u6ca1\u6709\u673a\u5668\u4eba\u529f\u80fd\u7684\uff0c\u5b98\u65b9\u6ca1\u6709\u7ed9\u51fa\u4efb\u4f55\u63a5\u53e3<\/em><\/strong><\/p>\n<h4>\u5b9e\u73b0\u539f\u7406\uff1a1\u3001hook \u5fae\u4fe1\u7684\u4e24\u79cd\u65b9\u5f0f<\/h4>\n<p>\u53c8\u53ef\u4ee5\u7ec6\u5316\u4e3a\u4e24\u79cd\u3002\u5373\u6709 hook PC \u7aef (Window \u7cfb\u7edf\uff09\u7684\u5fae\u4fe1\uff0c\u4e5f\u6709 hook \u624b\u673a\u7aef\uff08 Android \u7cfb\u7edf\uff09\u7684\u5fae\u4fe1\u3002<\/p>\n<ol>\n<li><strong>hook PC \u7aef\u7684\u4ee3\u8868\u4f5c\uff1awetool\u3001\u53ef\u7231\u732b<\/strong>\u3002\u529f\u80fd\u8d85\u7ea7\u5f3a\u5927\uff0c\u867d\u4e0d\u652f\u6301\u4e8c\u6b21\u5f00\u53d1\uff0c\u4f46\u5df2\u6709\u7684\u529f\u80fd\u8db3\u591f\u4e2a\u4eba\u4f7f\u7528\uff0c\u53ef\u60dc\u5b98\u65b9\u4f5c\u54c1\u5df2\u88ab\u817e\u8baf\u544a\u6b7b\uff0c\u597d\u5728\u5e02\u9762\u4e0a\u8fd8\u6d41\u843d\u7740\u4e0d\u5c11\u7834\u89e3\u7248\uff0c\u6709\u9700\u8981\u7684\u81ea\u884c\u641c\u7d22\u3002\u53e6\u5916\u8fd8\u6709\u4e00\u4e2a\u9700\u8981\u8fdb\u884c\u4e8c\u6b21\u5f00\u53d1\uff0c\u624d\u80fd\u4f7f\u7528\u7684\u975e\u4e3b\u6d41\u6846\u67b6\u53ef\u7231\u732b\uff0c\u9700\u8981\u7684\u81ea\u884c\u7814\u7a76\uff1b<\/li>\n<li><strong>hook \u79fb\u52a8\u7aef\u7684\u4ee3\u8868\u4f5c\uff1a\u592a\u6781<\/strong>\u3002\u529f\u80fd\u4e5f\u5f88\u5f3a\u5927\uff0c\u4e0d\u652f\u6301\u4e8c\u6b21\u5f00\u53d1\u3002\u4f7f\u7528\u8d77\u6765\u76f8\u5bf9\u6bd4\u8f83\u590d\u6742\uff0c\u4e00\u822c\u4eba\u73a9\u4e0d\u8d77\u6765\u3002 \uff08\u4e5f\u662f\u6211\u76ee\u524d\u5728\u7528\u7684\u5fae\u4fe1\u673a\u5668\u4eba\uff09<\/li>\n<\/ol>\n<p>\u65e0\u8bba\u662f PC \u7aef\u8fd8\u662f\u624b\u673a\u7aef\uff0c\u7528 hook \u65b9\u5f0f\u5b9e\u73b0\u7684\u6700\u5927\u7f3a\u70b9\u5c31\u662f\u8981\u548c\u67d0\u4e00\u4e2a\u7248\u672c\u7684\u5fae\u4fe1\u5ba2\u6237\u7aef\u8fdb\u884c\u7ed1\u5b9a\uff0c\u5982\u679c\u6846\u67b6\u672c\u8eab\u4e0d\u5bf9\u6700\u65b0\u7248\u672c\u7684\u5fae\u4fe1\u9002\u914d\uff0c\u90a3\u4f7f\u7528\u7684\u65f6\u5019\u5c31\u65e0\u6cd5\u5347\u7ea7\u5230\u6700\u65b0\u7248\u672c\u7684\u5fae\u4fe1\u3002<\/p>\n<h4>\u5b9e\u73b0\u539f\u7406\uff1a2\u3001\u6a21\u62df\u5fae\u4fe1\u901a\u4fe1\u534f\u8bae\u7684\u4e24\u79cd\u65b9\u5f0f<\/h4>\n<p>\u53c8\u53ef\u4ee5\u7ec6\u5316\u4e3a\u4e24\u79cd\u65b9\u5f0f\u3002<\/p>\n<ol>\n<li>\u901a\u8fc7\u6a21\u62df web \u534f\u8bae\u7684\u65b9\u5f0f \uff0c\u4ee3\u8868\u4f5c\uff1aItChat\u3002\u66fe\u7ecf\u7ea2\u6781\u4e00\u65f6\uff0c\u53f7\u79f0\u4e09\u5341\u884c\u5373\u53ef\u81ea\u5b9a\u4e49\u4e2a\u4eba\u53f7\u673a\u5668\u4eba\u3002\u53ef\u60dc\u7684\u662f\uff0c\u5fae\u4fe1\u5b98\u65b9\u5df2\u4e0d\u51c6\u8bb8\u65b0\u7684\u5fae\u4fe1\u53f7\u518d\u4f7f\u7528 web \u767b\u5f55\uff0c\u8fd9\u5c31\u76f4\u63a5\u4ece\u6e90\u5934\u627c\u6740\u4e86 web \u534f\u8bae\u7684\u5fae\u4fe1\u673a\u5668\u4eba\uff0c\u867d\u8bf4\u8001\u7684\u5fae\u4fe1\u53f7\u8fd8\u662f\u80fd\u51d1\u5408\u7740\u7528\uff0c\u4e0d\u8fc7\u90e8\u5206\u529f\u80fd\u4e5f\u53d7\u9650\u3002<\/li>\n<li>\u901a\u8fc7\u662f\u975e web \u534f\u8bae\uff0c\u5982 Pad \u534f\u8bae\u3001Mac \u534f\u8bae\uff0c\u4ee3\u8868\u4f5c\uff1awechaty\u3002\u5f53\u7136\u5b83\u81ea\u8eab\u4e5f\u652f\u6301 web \u534f\u8bae\uff0c\u800c\u4e14 web \u534f\u8bae\u7684\u673a\u5668\u4eba\u662f\u514d\u8d39\u7684\u3002\u8fd9\u54e5\u4eec\u6253\u7740\u5f00\u6e90\u7684\u5e4c\u5b50\uff0c\u4e3b\u8981\u4ee3\u7801\u5e76\u6ca1\u6709\u5f00\u6e90\uff0c\u53ea\u662f\u63d0\u4f9b\u4e86\u4e00\u5957 SDK \u800c\u5df2\uff0c\u9664\u4e86 web \u4ee5\u5916\u7684\u901a\u8baf\u534f\u8bae\u5747\u4ed8\u8d39\uff08\u5927\u6982 200 \u4e00\u4e2a\u6708\u5427\uff09\uff0c\u624d\u63d0\u4f9b\u8c03\u7528\u7684 token\u3002<\/li>\n<\/ol>\n<p>\u4ee5\u534f\u8bae\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\u4e0d\u9700\u8981\u548c\u5fae\u4fe1\u5ba2\u6237\u7aef\u7ed1\u5b9a\uff0c\u4f46\u4ed6\u4eec\u57fa\u672c\u4e0a\u90fd\u53ea\u63d0\u4f9b API\uff0c\u5e76\u4e0d\u662f\u53ef\u4ee5\u76f4\u63a5\u62ff\u6765\u7528\u7684\u6210\u54c1\uff0c\u9700\u8981\u8fdb\u884c\u4e8c\u6b21\u5f00\u53d1\u624d\u80fd\u4f7f\u7528\u3002\u4e8c\u6b21\u5f00\u53d1\u5bf9\u666e\u901a\u7528\u6237\u6765\u8bf4\u662f\u4e2a\u5de8\u5927\u7684\u95e8\u69db\uff0c\u4f46\u5bf9\u61c2\u7f16\u7a0b\u7684\u4eba\u6765\u8bf4\u662f\u4e2a\u5de8\u5927\u7684\u4f18\u70b9\uff0c\u8981\u5b9e\u73b0\u4ec0\u4e48\u529f\u80fd\u7531\u5f00\u53d1\u8005\u6765\u5b9a\u3002\u5982\u6700\u8fd1\u5f88\u706b\u7684 ChatGPT \u5927\u90fd\u662f\u901a\u8fc7 wechaty \u4e8c\u6b21\u5f00\u53d1\u63a5\u5165\u3002<\/p>\n<h4>\u4ece\u529f\u80fd\u4e0a\u6765\u8bf4<\/h4>\n<p>\u7406\u8bba\u4e0a\u624b\u673a\u7aef\u5fae\u4fe1\u673a\u5668\u4eba\u7684\u529f\u80fd\u662f\u591a\u4f59 PC \u7aef\u7684\u3002\u56e0\u4e3a\u624b\u673a\u7aef\u5fae\u4fe1\u7684\u529f\u80fd\u672c\u8eab\u5c31\u591a\u4f59\u6216\u8005\u8bf4\u9886\u5148 PC \u7aef\uff0c\u4f8b\u5982\u7ea2\u5305\u76f8\u5173\u7684\u529f\u80fd\uff0cPC \u7aef\u7684\u5fae\u4fe1\u5c31\u65e0\u6cd5\u5904\u7406\u5427\u3002\u6240\u4ee5\u62a2\u7ea2\u5305\u7684\u529f\u80fd\u5c31\u53ea\u80fd\u7531\u624b\u673a\u7aef\u7684\u5fae\u4fe1\u673a\u5668\u4eba\u6765\u505a\u3002<\/p>\n<p>\u4e0d\u8fc7\uff0cPC \u7aef\u7684\u5fae\u4fe1\u673a\u5668\u4eba\u5728\u4f7f\u7528\u4e0a\u6bd4\u624b\u673a\u7aef\u65b9\u4fbf\uff0c\u5c24\u5176\u662f\u7fa4\u7ba1\u7406\u76f8\u5173\u7684\u529f\u80fd\uff0c\u5728 PC \u4e0a\u4e00\u76ee\u4e86\u7136\uff0c\u4e00\u773c\u770b\u8fc7\u53bb\u5c31\u77e5\u9053\u5982\u4f55\u4f7f\u7528\u3002\u800c\u624b\u673a\u7aef\u5c31\u5f88\u9e21\u808b\uff0c\u5165\u53e3\u6df1\uff0c\u914d\u7f6e\u96be\uff01\u53e6\u5916\u5c31\u662fPC\u7aef\u7684\u5fae\u4fe1\u673a\u5668\u4eba\u5927\u90fd\u652f\u6301\u4e8c\u6b21\u5f00\u53d1\uff0c\u6269\u5c55\u6027\u5f88\u5f3a\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u8fd8\u662f\u8981\u6839\u636e\u81ea\u5df1\u7684\u4e1a\u52a1\u9700\u6c42\u9009\u62e9\u9002\u5408\u81ea\u5df1\u7684\u5fae\u4fe1\u673a\u5668\u4eba\u3002<\/p>\n<h3>3. \u65b9\u6848\u9009\u62e9<\/h3>\n<p>\u672c\u4eba\u5b9e\u6d4b\uff0c\u9009\u62e9\u4e86\u53ef\u7231\u732b\u6846\u67b6<\/p>\n<p>\u642d\u5efa\u73af\u5883\uff1a<\/p>\n<ul>\n<li>Windows11<\/li>\n<li>\u53ef\u7231\u732b5.2.7<\/li>\n<li>\u5fae\u4fe13.1.0.41<\/li>\n<\/ul>\n<p>\u94fe\u63a5\uff1a<a href=\"https:\/\/pan.baidu.com\/s\/1PDVo8VDr5mtRd4tu7z5tEw?pwd=ybch\">https:\/\/pan.baidu.com\/s\/1PDVo8VDr5mtRd4tu7z5tEw?pwd=ybch<\/a><br \/>\n\u63d0\u53d6\u7801\uff1aybch <\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230529200242365.png\" alt=\"image-20230529200242365\" \/> <\/p>\n<ul>\n<li>\u5176\u4ed6\u6846\u67b6\u63a8\u8350\uff1a<br \/>\n<a href=\"https:\/\/itchat.readthedocs.io\/zh\/latest\/\">https:\/\/itchat.readthedocs.io\/zh\/latest\/<\/a><br \/>\n<a href=\"https:\/\/gitee.com\/ikam\/wx-hook-http\">https:\/\/gitee.com\/ikam\/wx-hook-http<\/a><\/li>\n<\/ul>\n<h3>4.\u5b98\u65b9\u53c2\u8003\u94fe\u63a5<\/h3>\n<p><a href=\"https:\/\/www.ikam.cn\/thread-66.htm\">\u53ef\u7231\u732biHttp-\u9ad8\u6027\u80fd\u670d\u52a1\u7aef\u8bbe\u8ba1\u601d\u8def\uff5e-\u6613\u8bed\u8a00-i\u53ef\u7231\u732b\u8bba\u575b-\u53ef\u7231\u732b\u5c0f\u9ed1,\u81f4\u529b\u4e8e\u4e3a\u6613\u8bed\u8a00\u3001PHP\u8bed\u8a00\u4ea4\u6d41 (ikam.cn)<\/a><\/p>\n<p><a href=\"https:\/\/www.ikam.cn\/forum-1.htm\">\u6613\u8bed\u8a00-i\u53ef\u7231\u732b\u8bba\u575b-\u53ef\u7231\u732b\u5c0f\u9ed1,\u81f4\u529b\u4e8e\u4e3a\u6613\u8bed\u8a00\u3001PHP\u8bed\u8a00\u4ea4\u6d41 (ikam.cn)<\/a><\/p>\n<h2>\u4e8c\u3001\u53ef\u7231\u732b<\/h2>\n<h3>1.\u529f\u80fd\u6982\u8ff0<\/h3>\n<p>\u53ef\u7231\u732b\u7684ihttp\u63d2\u4ef6\uff0c\u903b\u8f91\u662f\uff0c\u901a\u8fc7\u53ef\u7231\u732b\u8f6f\u4ef6\u542f\u52a8\u6307\u5b9a\u7248\u672c\u7684\u5fae\u4fe1\uff0c\u5c06\u5fae\u4fe1\u7684\u5404\u79cd\u6536\u53d1\u7b49\u64cd\u4f5c\u901a\u8fc7sdk\u4e2d\u8f6c\uff0c\u63a5\u6536\u5230\u7684\u6d88\u606f\u4f1apost\u7ed9\u5f00\u53d1\u8005\u6307\u5b9a\u7684\u63a5\u53e3\uff0c\u5f00\u53d1\u8005\u4e5f\u53ef\u4ee5\u6309\u4e00\u5b9a\u7684\u683c\u5f0f\uff0c\u5c06\u64cd\u4f5c\u4fe1\u606fpost\u7ed9\u53ef\u7231\u732b\u7684SDK\uff0c\u4ee5\u5b8c\u6210\u5bf9\u5fae\u4fe1\u7684\u64cd\u4f5c<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/1_DZMRMHVSHT6GBMS.png\" alt=\"img\" \/><\/p>\n<h3>2.\u4f7f\u7528\u6d41\u7a0b<\/h3>\n<p>\u5b89\u88c5\u5c31\u4e0d\u8bf4\u4e86\uff0c\u4f46\u662f\u6ce8\u610f\uff0c\u4e0d\u540c\u7248\u672c\u7684\u53ef\u7231\u732b\uff0c\u8981\u5b89\u88c5\u6307\u5b9a\u7248\u672c\u7684\u5fae\u4fe1\u54e6<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230529201103709.png\" alt=\"image-20230529201103709\" \/> <\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230529201311535.png\" alt=\"image-20230529201311535\" \/> <\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230529201424408.png\" alt=\"image-20230529201424408\" \/><\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230529201548143.png\" alt=\"image-20230529201548143\" \/> <\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230529201851552.png\" alt=\"image-20230529201851552\" \/> <\/p>\n<h3>3.\u670d\u52a1\u7aef\u5f00\u53d1\u7b80\u8ff0<\/h3>\n<p>\u672c\u4eba\u4f7f\u7528flask\u5f00\u53d1\u4e86\u670d\u52a1\uff0c\u7aef\u53e38074\uff0c\u5e76\u914d\u7f6e\/weixin\u7684post\u63a5\u53e3\uff0c\u8fd9\u6837\u6240\u6709\u7684\u5fae\u4fe1\u4fe1\u606f\u90fd\u4f1a\u53d1\u5230\u6211\u8fd9\u91cc\u6765\uff0c\u6211\u5728\u5206\u6790\u4fe1\u606f\u540e\uff0c\u518d\u4f5c\u51fa\u76f8\u5e94\u7684\u56de\u590d\uff0c\u5982\u56de\u590d\u6d88\u606f\u3001\u53d1\u9001\u6587\u4ef6\u3001\u827e\u7279\u522b\u4eba\u4ec0\u4e48\u7684\uff0c\u6309\u53ef\u7231\u732b\u6307\u5b9a\u7684\u683c\u5f0f\uff0cpost\u7ed9<code>http:\/\/192.168.3.22\/8089<\/code><\/p>\n<h4>api\u53c2\u8003(\u4e0d\u662f\u6211\u5199\u7684\uff0c\u6709\u4e9b\u4e0d\u5bf9\u7684\uff0c\u591a\u8bd5\u8bd5\u53c2\u6570)<\/h4>\n<pre><code class=\"language-python\"># coding:utf-8\nimport json\nfrom typing import Optional\nfrom pydantic import BaseModel\nfrom fastapi.responses import Response\n\n&quot;&quot;&quot;\n\u6d88\u606f\u4e8b\u4ef6                      \u4e8b\u4ef6\u8bf4\u660e\n\nEventGroupMsg               \u7fa4\u6d88\u606f\u4e8b\u4ef6\nEventFriendMsg              \u79c1\u804a\u6d88\u606f\u4e8b\u4ef6\nEventReceivedTransfer       \u6536\u5230\u8f6c\u8d26\u4e8b\u4ef6\nEventScanCashMoney          \u9762\u5bf9\u9762\u6536\u6b3e\nEventFriendVerify           \u597d\u53cb\u8bf7\u6c42\u4e8b\u4ef6\nEventContactsChange         \u670b\u53cb\u53d8\u52a8\u4e8b\u4ef6\nEventGroupMemberAdd         \u7fa4\u6210\u5458\u589e\u52a0\u4e8b\u4ef6\nEventGroupMemberDecrease    \u7fa4\u6210\u5458\u51cf\u5c11\u4e8b\u4ef6\uff08\u7fa4\u6210\u5458\u9000\u51fa\uff09\nEventSysMsg                 \u7cfb\u7edf\u6d88\u606f\u4e8b\u4ef6\n&quot;&quot;&quot;\n\n&quot;&quot;&quot;\n\u4e8b\u4ef6\u53d1\u9001                      \u53d1\u9001\u8bf4\u660e\n\nSendTextMsg                 \u53d1\u9001\u6587\u672c\u6d88\u606f\nSendImageMsg                \u53d1\u9001\u56fe\u7247\u6d88\u606f\nSendVideoMsg                \u53d1\u9001\u89c6\u9891\u6d88\u606f\nSendFileMsg                 \u53d1\u9001\u6587\u4ef6\u6d88\u606f\nSendGroupMsgAndAt           \u53d1\u9001\u7fa4\u6d88\u606f\u5e76\u827e\u7279\nSendEmojiMsg                \u53d1\u9001\u52a8\u6001\u8868\u60c5\nSendLinkMsg                 \u53d1\u9001\u5206\u4eab\u94fe\u63a5\nSendMusicMsg                \u53d1\u9001\u97f3\u4e50\u5206\u4eab\nGetRobotName                \u53d6\u767b\u5f55\u8d26\u53f7\u6635\u79f0\nGetRobotHeadimgurl          \u53d6\u767b\u5f55\u8d26\u53f7\u5934\u50cf\nGetLoggedAccountList        \u53d6\u767b\u5f55\u8d26\u53f7\u5217\u8868\nGetFriendList               \u53d6\u597d\u53cb\u5217\u8868\nGetGroupList                \u53d6\u7fa4\u804a\u5217\u8868\nGetGroupMemberList          \u53d6\u7fa4\u6210\u5458\u5217\u8868\nGetGroupMemberInfo          \u53d6\u7fa4\u6210\u5458\u8be6\u7ec6\nAcceptTransfer              \u63a5\u6536\u597d\u53cb\u8f6c\u8d26\nAgreeGroupInvite            \u540c\u610f\u7fa4\u804a\u9080\u8bf7\nAgreeFriendVerify           \u540c\u610f\u597d\u53cb\u8bf7\u6c42\nEditFriendNote              \u4fee\u6539\u597d\u53cb\u5907\u6ce8\nDeleteFriend                \u5220\u9664\u597d\u53cb\nGetappInfo                  \u53d6\u63d2\u4ef6\u4fe1\u606f\nGetAppDir                   \u53d6\u5e94\u7528\u76ee\u5f55\nAddAppLogs                  \u6dfb\u52a0\u65e5\u5fd7\nReloadApp                   \u91cd\u8f7d\u63d2\u4ef6\nRemoveGroupMember           \u8e22\u51fa\u7fa4\u6210\u5458\nEditGroupName               \u4fee\u6539\u7fa4\u540d\u79f0\nEditGroupNotice             \u4fee\u6539\u7fa4\u516c\u544a\nBuildNewGroup               \u5efa\u7acb\u65b0\u7fa4\nQuitGroup                   \u9000\u51fa\u7fa4\u804a\nInviteInGroup               \u9080\u8bf7\u52a0\u5165\u7fa4\u804a\n&quot;&quot;&quot;\n\nclass AcceptEvent(BaseModel):\n    &quot;&quot;&quot;\n    \u6d88\u606f\u63a5\u6536\u6a21\u578b\n    &quot;&quot;&quot;\n    # \u6ce8\uff1a\u5728\u79c1\u804a\u4e8b\u4ef6\u4e0b\uff0cfrom_wxid\u548cfinal_from_wxid\u4e00\u81f4\n    # \u6d88\u606f\u4e8b\u4ef6\n    event: Optional[str] = None\n    # \u673a\u5668\u4eba\u5fae\u4fe1ID\n    robot_wxid: Optional[str] = None\n    # \u673a\u5668\u4eba\u6635\u79f0\n    robot_name: Optional[str] = None\n    # \u6d88\u606f\u7c7b\u578b  1\/\u6587\u672c\u6d88\u606f 3\/\u56fe\u7247\u6d88\u606f 34\/\u8bed\u97f3\u6d88\u606f  42\/\u540d\u7247\u6d88\u606f  43\/\u89c6\u9891 47\/\u52a8\u6001\u8868\u60c5 48\/\u5730\u7406\u4f4d\u7f6e  49\/\u5206\u4eab\u94fe\u63a5  2000\/\u8f6c\u8d26 2001\/\u7ea2\u5305  2002\/\u5c0f\u7a0b\u5e8f  2003\/\u7fa4\u9080\u8bf7\n    type: Optional[int] = None\n    # \u5fae\u4fe1\u7fa4ID\n    from_wxid: Optional[str] = None\n    # \u7fa4\u540d\u79f0\n    from_name: Optional[str] = None\n    # \u53d1\u4fe1\u4eba\n    final_from_wxid: Optional[str] = None\n    # \u53d1\u4fe1\u4eba\u6635\u79f0\n    final_from_name: Optional[str] = None\n    # \u63a5\u6536\u6d88\u606f\u7684\u7fa4\/\u4eba\n    to_wxid: Optional[str] = None\n    # \u6d88\u606f\u5185\u5bb9\n    msg: Optional[str] = None\n    # \u91d1\u989d\n    money: Optional[float] = None\n\ndef SendTextMsg(robot_wxid, to_wxid, msg):\n    &quot;&quot;&quot;\n    \u53d1\u9001\u666e\u901a\u6587\u672c\u6d88\u606f\n    :param robot_wxid:\u673a\u5668\u4ebaID\n    :param to_wxid:\u6d88\u606f\u63a5\u6536ID \u4eba\/\u7fa4\n    :param msg:\u6587\u672c\u6d88\u606f\n    :return:\u53d1\u9001\u6d88\u606f\n    &quot;&quot;&quot;\n    data = dict()\n    data[&quot;event&quot;] = &quot;SendTextMsg&quot;\n    data[&quot;robot_wxid&quot;] = robot_wxid\n    data[&quot;to_wxid&quot;] = to_wxid\n    data[&quot;msg&quot;] = str(msg)\n    data = json.dumps(data)\n    return Response(data)\n\ndef SendImageMsg(robot_wxid, to_wxid, path, name):\n    &quot;&quot;&quot;\n    \u53d1\u9001\u56fe\u7247\u6d88\u606f\n    :param robot_wxid: \u673a\u5668\u4ebaID\n    :param to_wxid: \u6d88\u606f\u63a5\u6536ID \u4eba\/\u7fa4\n    :param path: \u56fe\u7247URL\u8def\u5f84\n    :param name: \u56fe\u7247\u552f\u4e00\u540d\u79f0\n    :return: \u53d1\u9001\u56fe\u7247\u6d88\u606f\n    &quot;&quot;&quot;\n    data = dict()\n    msg = dict()\n    data[&quot;event&quot;] = &quot;SendImageMsg&quot;\n    data[&quot;robot_wxid&quot;] = robot_wxid\n    data[&quot;to_wxid&quot;] = to_wxid\n    msg[&quot;url&quot;] = path\n    msg[&#039;name&#039;] = name\n    data[&#039;msg&#039;] = msg\n    data = json.dumps(data)\n    return Response(data)\n\ndef SendVideoMsg(robot_wxid, to_wxid, path, name):\n    &quot;&quot;&quot;\n    \u53d1\u9001\u89c6\u9891\u6d88\u606f\n    :param robot_wxid: \u673a\u5668\u4ebaID\n    :param to_wxid: \u6d88\u606f\u63a5\u6536ID \u4eba\/\u7fa4\n    :param path: \u89c6\u9891URL\u8def\u5f84\n    :param name: \u89c6\u9891\u552f\u4e00\u540d\u79f0\n    :return: \u53d1\u9001\u89c6\u9891\u6d88\u606f\n    &quot;&quot;&quot;\n    data = dict()\n    msg = dict()\n    data[&quot;event&quot;] = &quot;SendVideoMsg&quot;\n    data[&quot;robot_wxid&quot;] = robot_wxid\n    data[&quot;to_wxid&quot;] = to_wxid\n    msg[&quot;url&quot;] = path\n    msg[&#039;name&#039;] = name\n    data[&#039;msg&#039;] = msg\n    data = json.dumps(data)\n    return Response(data)\n\ndef SendFileMsg(robot_wxid, to_wxid, path, name):\n    &quot;&quot;&quot;\n    \u53d1\u9001\u6587\u4ef6\u6d88\u606f\n    :param robot_wxid: \u673a\u5668\u4ebaID\n    :param to_wxid: \u6d88\u606f\u63a5\u6536ID \u4eba\/\u7fa4\n    :param path: \u6587\u4ef6URL\u8def\u5f84\n    :param name: \u6587\u4ef6\u552f\u4e00\u540d\u79f0\n    :return: \u53d1\u9001\u6587\u4ef6\u9891\u6d88\u606f\n    &quot;&quot;&quot;\n    data = dict()\n    msg = dict()\n    data[&quot;event&quot;] = &quot;SendFileMsg&quot;\n    data[&quot;robot_wxid&quot;] = robot_wxid\n    data[&quot;to_wxid&quot;] = to_wxid\n    msg[&#039;name&#039;] = name\n    msg[&quot;url&quot;] = path\n    data[&#039;msg&#039;] = msg\n    data = json.dumps(data)\n    return Response(data)\n\n&#039;robot_wxid, group_wxid, member_wxid, member_name, msg&#039;\n\ndef SendGroupMsgAndAt(robot_wxid, to_wxid, at_id, at_name, msg):\n    &quot;&quot;&quot;\n    \u53d1\u9001@\u6d88\u606f\n    :param robot_wxid:\u673a\u5668\u4ebaID\n    :param to_wxid:\u6d88\u606f\u63a5\u6536\u7684\u7fa4ID\n    :param at_id:\u9700\u8981@\u7684\u4ebaID\n    :param at_name:\u9700\u8981@\u4eba\u7684\u540d\u79f0\n    :param msg:\u6587\u672c\u6d88\u606f\n    :return:\u53d1\u9001\u6d88\u606f\n    &quot;&quot;&quot;\n    data = dict()\n    data[&quot;event&quot;] = &quot;SendGroupMsgAndAt&quot;\n    data[&quot;robot_wxid&quot;] = robot_wxid\n    data[&quot;group_wxid&quot;] = to_wxid\n    data[&#039;member_wxid&#039;] = at_id\n    data[&#039;member_name&#039;] = at_name\n    data[&#039;msg&#039;] = msg\n    data = json.dumps(data)\n    return Response(data)\n\ndef SendEmojiMsg(robot_wxid, to_wxid, path, name):\n    &quot;&quot;&quot;\n    \u53d1\u9001\u52a8\u6001\u8868\u60c5\n    :param robot_wxid: \u673a\u5668\u4ebaID\n    :param to_wxid: \u63a5\u6536\u6d88\u606fID \u4eba\/\u7fa4\n    :param path: URL\u8def\u5f84\n    :param name: \u6587\u4ef6\u552f\u4e00\u540d\u79f0\n    :return: \u53d1\u9001\u6d88\u606f\n    &quot;&quot;&quot;\n    data = dict()\n    msg = dict()\n    data[&quot;event&quot;] = &quot;SendEmojiMsg&quot;\n    data[&quot;robot_wxid&quot;] = robot_wxid\n    data[&quot;to_wxid&quot;] = to_wxid\n    msg[&#039;name&#039;] = name\n    msg[&quot;url&quot;] = path\n    data[&#039;msg&#039;] = msg\n    data = json.dumps(data)\n    return Response(data)\n\ndef SendLinkMsg(robot_wxid, to_wxid, title, text, target_url, pic_url=&#039; &#039;, icon_url=&#039; &#039;):\n    &quot;&quot;&quot;\n    \u53d1\u9001\u94fe\u63a5\u5361\u7247\u6d88\u606f\n    :param robot_wxid: \u673a\u5668\u4ebaID\n    :param to_wxid: \u63a5\u6536\u6d88\u606fID \u4eba\/\u7fa4\n    :param title: \u94fe\u63a5\u5361\u7247\u6807\u9898\n    :param text: \u94fe\u63a5\u5361\u7247\u6587\u672c\n    :param target_url: \u94fe\u63a5\u5361\u7247URL\n    :param pic_url:\n    :param icon_url: \u94fe\u63a5\u5361\u7247\u56fe\u6807\n    :return: \u53d1\u9001\u94fe\u63a5\u5361\u7247\u6d88\u606f\n    &quot;&quot;&quot;\n    data = dict()\n    msg = dict()\n    data[&quot;event&quot;] = &quot;SendLinkMsg&quot;\n    data[&quot;robot_wxid&quot;] = robot_wxid\n    data[&quot;to_wxid&quot;] = to_wxid\n    msg[&#039;title&#039;] = title\n    msg[&#039;text&#039;] = text\n    msg[&#039;target_url&#039;] = target_url\n    msg[&#039;pic_url&#039;] = pic_url\n    msg[&#039;icon_url&#039;] = icon_url\n    data[&#039;msg&#039;] = msg\n    data = json.dumps(data)\n    return Response(data)<\/code><\/pre>\n<h4>\u6211\u7684<\/h4>\n<p>\u53c2\u8003\u4e86\u8fd9\u54e5\u4eec\u7684\u4ee3\u7801<a href=\"https:\/\/blog.csdn.net\/u010418732\/article\/details\/126942827?spm=1001.2014.3001.5501\">\u53ef\u7231\u732b+python3+Flask+aiohttp\u7b80\u5355\u642d\u5efa\u5fae\u4fe1\u673a\u5668\u4eba_\u5fae\u4fe1\u673a\u5668\u4eba\u6846\u67b6_Tokeii\u7684\u535a\u5ba2-CSDN\u535a\u5ba2<\/a><\/p>\n<p>\u7f3a\u51fd\u6570\u7684\u8bdd\u76f4\u63a5\u6284\u4ed6\u7684\u5427\uff0c\u6709\u7a7a\u518d\u6574\u7406\u5230github\u4e0a\uff0c\u603b\u7684\u6d41\u7a0b\u5c31\u662f\u8fd9\u6837<\/p>\n<p><a href=\"https:\/\/github.com\/lemonguess\/wechatRob\">lemonguess\/wechatRob (github.com)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u5fae\u4fe1\u673a\u5668\u4eba\u6982\u8ff0 1.\u4f01\u4e1a\u5fae\u4fe1\u673a\u5668\u4eba \u521a\u5f00\u59cb\u60f3\u7814\u7a76\u4e0b\u5fae\u4fe1\u673a\u5668\u4eba\uff0c\u4e86\u89e3\u5230\u4f01\u4e1a\u5fae\u4fe1\u7c7b\u4f3c\u4e8e\u9489\u9489\uff0c\u5f00\u653e\u4e86api\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u8fdb\u884c\u8c03\u7528\uff0c\u4ee5\u4fbf\u4e8e\u5b8c\u6210   \u2026 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[163],"tags":[16,165,164],"_links":{"self":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts\/8770"}],"collection":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8770"}],"version-history":[{"count":2,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/8770\/revisions"}],"predecessor-version":[{"id":8775,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/8770\/revisions\/8775"}],"wp:attachment":[{"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8770"},{"taxonomy":"post_tag","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}