{ "info": { "author": "lspvic", "author_email": "lspvic@qq.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: Chinese (Simplified)", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "yawxt: \u53c8\u4e00\u4e2a\u5fae\u4fe1\u516c\u4f17\u53f7\u5f00\u53d1\u5de5\u5177\u7bb1\n=================================\n\n|build-status| |pypi-status| |pypi-pyversions| |docs|\n\nYet Another WeiXin(wechat) Toolkit\n\ngithub\uff1ahttps://github.com/lspvic/yawxt/\n\n\u6587\u6863\uff1a https://yawxt.readthedocs.io/\n\n\u5b9e\u4f53\u5bf9\u8c61\n--------\n#. \u6d88\u606f\u5bf9\u8c61 ``yawxt.Message``\n#. \u7528\u6237\u5bf9\u8c61 ``yawxt.User``\n#. \u4f4d\u7f6e\u5bf9\u8c61 ``yawxt.Location``\n\n\u4f7f\u7528\u6570\u636e\u5bf9\u8c61\u53ef\u4ee5\u5f88\u597d\u7684\u7ba1\u7406\u548c\u8bbf\u95ee\u5fae\u4fe1\u6570\u636e\u8d44\u6e90\uff0c\u5982::\n\n user.nickname, user.headimgurl, user.city\n location.latitude, location.longitude, location.time\n message.msg_type, message.msg_id, message.create_time\n\n\u516c\u4f17\u53f7API\n---------\n\u7c7b ``yawxt.WxClient`` \u5c01\u88c5\u516c\u4f17\u53f7API\n\n.. code-block:: python\n\n >>> from yawxt import WxClient\n >>> client = WxClient(\"appid\", \"appsecret\")\n >>> it = client.get_openid_iter()\n >>> openid = next(it)\n >>> openid\n 'o9KLls70ReakhjebmHUYxjbz9K8c'\n >>> user = client.get_user(openid)\n >>> user\n {\"openid\": \"o9KLls70ReakhjebmHUYxjbz9K8c\", \"nickname\": \"yawxt\", ...}\n >>> user.city\n '\u676d\u5dde'\n\n\n\u6d88\u606f\u5bf9\u8bdd\n--------\n\u7c7b ``yawxt.MessageHandler`` \u5904\u7406\u63a5\u6536\u6d88\u606f\u4e8b\u4ef6\n\n.. code-block:: python\n\n from yawxt import MessageHandler, WxClient, check_signature\n\n # \u5b9a\u4e49\u6d88\u606f\u56de\u590d\u5185\u5bb9\n class Handler(MessageHandler):\n\n # \u5f53\u6536\u5230\u4e00\u6761\u6587\u672c\u6d88\u606f\u65f6\n def on_text(self, text):\n # \u56de\u590d\u4e00\u6761\u6587\u672c\u6d88\u606f\n # \u53ef\u4ee5\u4f7f\u7528\u5df2\u5b9a\u4e49\u7684user\u5bf9\u8c61\n self.reply_text(\"\u4f60\u597d:%s\" % self.user.nickname)\n\n # \u5f53\u6536\u5230\u5730\u7406\u4f4d\u7f6e\u4e0a\u62a5\u4e8b\u4ef6\u65f6\n def event_location(self,location):\n # \u4fdd\u5b58\u5730\u7406\u4f4d\u7f6e\n redis.hset(\"location::%s\" % self.openid, \n {\"lat\": location.latitude, \"lon\": location.longitude})\n\n # \u5f53\u6536\u5230\u4e00\u6761\u56fe\u7247\u6d88\u606f\u65f6\n def on_image(self, media_id, pic_url): \n # \u53ef\u4ee5\u8c03\u7528\u516c\u4f17\u53f7API\uff0c\u4e0b\u8f7d\u5230\u672c\u5730\n r = self.client.download_image(media_id)\n with open(\"/path/to/images/%s.jpg\" % media_id, \"rb\") as f:\n f.write(r.content)\n # \u56de\u590d\u540c\u6837\u7684\u56fe\u7247\n self.reply_image(media_id) \n\n client = WxClient(appid, secret, token)\n\n # \u5728web\u6846\u67b6\u4e2d\u56de\u590d\u6d88\u606f\uff0c\u4ee5Flask\u4e3a\u4f8b\n app = Flask(__name__)\n session_maker = sessionmaker(bind=engine)\n token = \"token\" # \u516c\u4f17\u53f7\u540e\u53f0\u914d\u7f6eToken\n @app.route('/wechat', methods=[\"GET\", \"POST\"])\n def wechat():\n signature = request.args.get('signature')\n timestamp = request.args.get('timestamp')\n nonce = request.args.get('nonce')\n if not check_signature(token, timestamp, nonce, signature):\n return \"Messages not From Wechat\"\n if request.method == \"GET\":\n return request.args.get('echostr')\n\n msg = PersistMessageHandler(request.data, wechat_account,\n db_session_maker=session_maker,\n debug_to_wechat=app.debug)\n return msg.reply()\n\n\u6d88\u606f\u6301\u4e45\u5316\n------------\n\n\u4f7f\u7528\u7c7b ``yawxt.persistence.PersistMessageHandler`` \uff0c\u4e0d\u505a\u4efb\u4f55\u5904\u7406\u5c31\u80fd\u591f\u76f4\u63a5\u5c06\u63a5\u6536\u7684\u6d88\u606f\u3001\n\u7528\u6237\u4fe1\u606f\u3001\u4e0a\u62a5\u4f4d\u7f6e\u4fe1\u606f\u4fdd\u5b58\u5230\u6570\u636e\u5e93\u4e2d\uff1a\n\n.. code-block:: python\n\n from yawxt.persistence import PersistMessageHandler\n\n Session = session_maker(bind=engine)\n message = PersistMessageHandler(content, client=client, \n db_session_maker=Session, debug_to_wechat=True)\n return_str = message.reply()\n\n\u7ee7\u627f ``PersistMessageHandler`` \uff0c\u53ea\u5173\u6ce8\u81ea\u5df1\u7684\u5904\u7406\u903b\u8f91\uff0c\u6240\u6709\u6d88\u606f\u7684\u63a5\u6536\n\u4e0e\u53d1\u9001\u90fd\u6301\u4e45\u5316\u5230\u6570\u636e\u5e93\u4e2d\u4e86\u3002\n\n\u66f4\u591a\u7684\u4f8b\u5b50\u5728 `examples `_ \u6587\u4ef6\u5939\u4e0b\u9762\n\n\u5b89\u88c5\n----\n\u4f7f\u7528pip\u5b89\u88c5yawxt:\n\n``pip install yawxt``\n\n\u5982\u679c\u8981\u4f7f\u7528\u6d88\u606f\u6301\u4e45\u5316\uff0c\u8fd8\u9700\u8981\u5b89\u88c5sqlalchemy\u53ca\u6570\u636e\u5e93\u9a71\u52a8\uff0c\u5982mysql\u7684PyMySQL\uff1a\n\n``pip install sqlalchemy PyMySQL``\n\n.. |build-status| image:: https://img.shields.io/travis/lspvic/yawxt.svg\n :target: https://travis-ci.org/lspvic/yawxt\n\n.. |pypi-status| image:: https://img.shields.io/pypi/v/yawxt.svg\n :target: https://pypi.python.org/pypi/yawxt\n\n.. |pypi-pyversions| image:: https://img.shields.io/pypi/pyversions/yawxt.svg\n :target: https://pypi.python.org/pypi/yawxt\n\n.. |docs| image:: https://readthedocs.org/projects/yawxt/badge/?version=latest\n :alt: Documentation Status\n :target: https://readthedocs.org/projects/yawxt/\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/lspvic/yawxt", "keywords": "wechat,weixin,Official Account,\u5fae\u4fe1,\u516c\u4f17\u53f7", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "yawxt", "package_url": "https://pypi.org/project/yawxt/", "platform": "", "project_url": "https://pypi.org/project/yawxt/", "project_urls": { "Homepage": "http://github.com/lspvic/yawxt" }, "release_url": "https://pypi.org/project/yawxt/0.1.2/", "requires_dist": [ "requests-oauthlib", "pyOpenSSL ; python_version == \"2.6\"" ], "requires_python": "", "summary": "\u53c8\u4e00\u4e2a\u5fae\u4fe1\u516c\u4f17\u53f7\u5f00\u53d1\u5de5\u5177\u7bb1 Yet Another WeiXin(wechat) Tookit", "version": "0.1.2" }, "last_serial": 5472214, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "88af21b44c2d467e0f6556e58a78d5fe", "sha256": "bd79fa20359c6bbc037dd235127367bcd78f31f838022dc1493f16a8f41eebe1" }, "downloads": -1, "filename": "yawxt-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "88af21b44c2d467e0f6556e58a78d5fe", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 22997, "upload_time": "2017-08-21T07:37:39", "url": "https://files.pythonhosted.org/packages/55/05/dd86e5a79391de3a50db6c92b248c145f3a80ad4bb245c23256b58cc819e/yawxt-0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e2d5592b4d8be6cea39afbe698004892", "sha256": "94f592315cdadc6d462b4a9326f30f6fd2af4356dcf8003b6b0ea4901002892f" }, "downloads": -1, "filename": "yawxt-0.1.tar.gz", "has_sig": false, "md5_digest": "e2d5592b4d8be6cea39afbe698004892", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17247, "upload_time": "2017-08-21T07:37:40", "url": "https://files.pythonhosted.org/packages/5f/80/511d990da82f47392c16dc89a601eb4486f7913efe1373e22763555fe509/yawxt-0.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "f7e3ccb1e48ff50f97fbdfa78fece2f7", "sha256": "24e216dd8fc75a0c629403f48c6aa8f1dc49d88db948f885420acf98bf27dbf0" }, "downloads": -1, "filename": "yawxt-0.1.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f7e3ccb1e48ff50f97fbdfa78fece2f7", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 21022, "upload_time": "2019-07-01T17:47:51", "url": "https://files.pythonhosted.org/packages/68/4d/b6326cf70b07932bef497c55c05c771c64041f18db47c7fefb4816987d5e/yawxt-0.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "02ad2576bfd1ce791dd652bd1aa5cc3c", "sha256": "810fae7d753670a9cadb405b9560cc04ed3a118445002bb617b8edae0d2d865e" }, "downloads": -1, "filename": "yawxt-0.1.2.tar.gz", "has_sig": false, "md5_digest": "02ad2576bfd1ce791dd652bd1aa5cc3c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19299, "upload_time": "2019-07-01T17:47:53", "url": "https://files.pythonhosted.org/packages/39/d2/f9f984675212872abc0461426db3ee47fc038b35a79371cbe26f9bffea3c/yawxt-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f7e3ccb1e48ff50f97fbdfa78fece2f7", "sha256": "24e216dd8fc75a0c629403f48c6aa8f1dc49d88db948f885420acf98bf27dbf0" }, "downloads": -1, "filename": "yawxt-0.1.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f7e3ccb1e48ff50f97fbdfa78fece2f7", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 21022, "upload_time": "2019-07-01T17:47:51", "url": "https://files.pythonhosted.org/packages/68/4d/b6326cf70b07932bef497c55c05c771c64041f18db47c7fefb4816987d5e/yawxt-0.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "02ad2576bfd1ce791dd652bd1aa5cc3c", "sha256": "810fae7d753670a9cadb405b9560cc04ed3a118445002bb617b8edae0d2d865e" }, "downloads": -1, "filename": "yawxt-0.1.2.tar.gz", "has_sig": false, "md5_digest": "02ad2576bfd1ce791dd652bd1aa5cc3c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19299, "upload_time": "2019-07-01T17:47:53", "url": "https://files.pythonhosted.org/packages/39/d2/f9f984675212872abc0461426db3ee47fc038b35a79371cbe26f9bffea3c/yawxt-0.1.2.tar.gz" } ] }