微信接服务商(E管家)API python 接口
Project description
ewechat
以前有很多基于 Web 微信的库,比如 itchat 等,在微信限制 web 微信该协议后这些库就无法使用了。现在如果想 hook 微信出接口,基本都要使用一些付费的服务,比如 wechaty PadLocal,这也是我一直在用的服务,但是 wechaty 一直没有实现朋友圈等功能。
这个E 云管家也是基于微信 iPad 协议,价格和 PadLoacal 一样(每个微信号每月 200 元)。由于已经实现了我需要的朋友圈功能,所以最近把自己的服务迁移到了这里。
⚠️ 提示
我在使用这家服务,但并不作为推荐。与微信的 web 协议不同,如果使用这个服务,服务商可以获取你微信的全部隐私。而且这是对微信协议的破解,账号有被封禁的风险,请慎重使用。
开发进度
这个服务商的 API 接口非常简单,官方文档接口数量不多。为了方便我自己日常使用,我打算把官方 API 接口封装成 python SDK。代码比较简单,有时间的话我尽快写完。
使用方法
该包是基于服务商 API 实现的,请在服务商处注册并购买相应资源后再进行配置。请先阅读服务商文档,否则可能不理解相关的参数。
下载安装该包:
python3 -m pip install ewechat
登录
from ewechat import Wechat
# 实例化时请传入服务商提供的 url、账号和密码,
# 目的是为了获得授权码
my_wechat = Wechat(base_url=url, account="your_account", password="your_password")
# 如果已经获得了授权码,可以直接传入授权码
my_wechat = Wechat(base_url=url, auth=authorization)
# 进行登录,在弹出二维码后请用手机扫码登录
my_wechat.login()
# 如果是在远程主机运行,无法弹出二维码,需要手动打开图片扫码后执行
my_wechat.write_file()
# 登录完成后会在当前目录创建文件 logged_in
# 记录你的一些参数,参数的意义请参照服务商文档
通讯录
初始化通讯录列表
my_wechat.init_address_list()
获取通讯录列表
my_wechat.get_address_list()
获取联系人信息
my_wechat.get_contact(wcId: str)
消息发送
发送文本消息
my_wechat.send_text(wcId: str, content: str)
发送文件消息
my_wechat.send_file(wcId: str, path: str, fileName: str)
发送图片消息
my_wechat.send_image(wcId: str, content: str)
发送视频消息
my_wechat.send_video(path: str, thumbPath: str)
发送 URL 消息
my_wechat.send_url(wcId, title, url, description, thumbUrl)
消息接收
设置消息接收地址
返回 None 即设置成功,如果设置失败会引发异常。
my_wechat.set_http_callback_url(httpUrl: str, type: int)
取消消息接收
my_wechat.cancel_http_callback_url()
下载图片
type
0 是常规图片,1 是高清图。
my_wechat.get_msg_img(msgId: str, content: str, type: int = 1)
朋友圈
获取指定好友朋友圈
第一次使用 firstPageMd5
和 maxId
请留空。
my_wechat.get_friend_circle(wcId: str, firstPageMd5: str = "", maxId: int = 0)
发送文字朋友圈
my_wechat.sns_send(content: str)
发送图片朋友圈
my_wechat.sns_send_image(content: str, paths: str, groupUser: str = None, blackList: str = None)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ewechat-0.1.6-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36037defe6c154a4ddf5b85eb4ea3e813d0d652e2050e61463eeffacfb93f2b2 |
|
MD5 | 9d48285cb6999e902162642fff759a2b |
|
BLAKE2b-256 | 15be183ab0107eb599d3723b7fae0ab8a9fd14574b168e517c536d98b142945e |