MPESA Crane API的一个瘦异步包装器。
aiompesa的Python项目详细描述
aiompesa
用于从asyncio访问MPESA Daraja API的包。
用法
importasynciofromaiompesaimportMpesaCONSUMER_KEY="nF4OwB2XiuYZwmdMz3bovnzw2qMls1b7"CONSUMER_SECRET="biIImmaAX9dYD4Pw"loop=asyncio.get_event_loop()mpesa=Mpesa(True,CONSUMER_KEY,CONSUMER_SECRET)token_response=loop.run_until_complete(mpesa.generate_token())access_token=token_response.get("access_token",None)expires_in=token_response.get("expires_in",None)ifaccess_tokenisNone:print("Error: Wrong credentials used to get the access_token")else:print(f"access_token = {access_token}, expires_in = {expires_in} secs")
要求
- Python3.6+
安装
$ pip install aiompesa
动机
- 学习更多关于
asyncio
的知识并付诸实践。 - 为Safaricom daraja api开发异步包装。