Coder Social home page Coder Social logo

justdoit0823 / pywxclient Goto Github PK

View Code? Open in Web Editor NEW
275.0 31.0 51.0 58 KB

A simple WeChat client written in Python supports session persistence.

Home Page: http://pywxclient.readthedocs.io/en/latest/index.html

License: Apache License 2.0

Python 100.00%
wechat-bot wechat-sdk wechat-framework pywxclient

pywxclient's Introduction

pywxclient

https://travis-ci.org/justdoit0823/pywxclient.svg?branch=master

A simple WeChat client is based on Web HTTP api, supporting authorization, login, fetching message and sending message.

Here we go:

>>> from pywxclient.core import Session, SyncClient

>>> s1 = Session()

>>> c1 = SyncClient(s1)

>>> c1.get_authorize_url()  # Open the url in web browser

>>> c1.authorize()  # Continue authorize when returning False

>>> c1.login()

>>> c1.sync_check()

>>> msgs = c1.sync_message()  # Here are your wechat messages

>>> c1.flush_sync_key()

Features

  • WeChat authorization
  • WeChat login
  • Fetching WeChat contacts
  • Fetching all possible messages
  • Send text message
  • Send image message
  • Send video message
  • Send file message
  • Dump client as a dict
  • Load client from a dict
  • Local or network files uploading

pywxclient aims to only support Python 3, so there is no guarantee for Python 2.

Installation

We can simply use pip to install, as the following:

$ pip install pywxclient

or installing from git

$ pip install git+https://github.com/justdoit0823/pywxclient

Examples

In the examples directory, there are two simple python wechat client program as tutorials.

Or you can write a more complex wechat client with this pywxclient package.

Documentation

Now, the guys can visit website pywxclient or build documentation as html files on local machines.

CHANGELOG

Go to CHANGELOG.md.

How to Contribute

Open an issue, join a discussion or make a pull request.

pywxclient's People

Contributors

justdoit0823 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pywxclient's Issues

Can not login anymore

Hi,Developer, the repo of your maybe have some login issue,Do you have any plane to fix it?
Snipaste_2019-09-26_21-37-53

windows 10 cant pip install

C:\Program Files\Python36\Scripts>pip3.6.exe install pywxclient
Collecting pywxclient
Could not find a version that satisfies the requirement pywxclient (from versions: )
No matching distribution found for pywxclient

C:\Program Files\Python36\Scripts>pip.exe install pywxclient
Collecting pywxclient
Could not find a version that satisfies the requirement pywxclient (from versions: )
No matching distribution found for pywxclient

期待更多的示例或更加完善的文档 ~

目前,很难知道这个库到底提供了哪些 API,光从 examples 中的两个例子来学习使用方法比较困难

既然这个库已经发了两个版本了, 作者能不能把文档给文档补充一下呐?

Session expiration

Hi!

Is there any way to keep the session for a long time (even several days maybe?).

All I can think is to send a message every minute or two, for instance, but perhaps you are using a better way.

Thanks!

无法登录

LoginError: 当前登录环境异常。为了你的帐号安全,暂时不能登录web微信。你可以通过手机客户端或者windows微信登录。

Sending voice message from file on PC

Hi,
Firstly, this is a great tool.
I have a *.AMR voice message saved on my local drive and I want to send it to one of my contacts.
Looking through the code I can see there is a VoiceMessage function, but can't figure out how to use it with a local file. Any help very much appreciated.
KR,
Lawrence.

Client cannot run for newly registered accounts

Hi, I am trying to run your code and specifically the client example with a new wechat account I created and I receive this error which seems to be related to a new policy wechat introduced. Is there any way around that you are familiar with?

For account security, newly registered WeChat accounts are unable to log in to Web WeChat. To use WeChat on a computer, use Windows WeChat or Mac WeChat at http://wechat.com

Cannot send a message (APIResponseError)

I always get APIResponseError (without any details) when I try to send a message.

from pywxclient.core import Session, SyncClient, TextMessage

session = Session()
client = SyncClient(session)
client.get_authorize_url()
# open url and scan QR with phone
client.authorize()
client.login()

user_from = "@my_user_id"
user_to = "@friends_user_id"
msg = "test123"
tm = TextMessage(user_from, user_to, msg)

client.send_message(tm)
---------------------------------------------------------------------------
APIResponseError                          Traceback (most recent call last)
<ipython-input-3-952420276ad7> in <module>()
      3 msg = "test123"
      4 tm = TextMessage(user_from, user_to, msg)
----> 5 client.send_message(tm)

~/.virtualenvs/hype/lib/python3.6/site-packages/pywxclient/core/client.py in send_message(self, message)
    201 
    202         msg_ret = self.msg_send_routines[message.msg_type](
--> 203             self.session, message)
    204 
    205         local_msg_id = msg_ret['LocalID']

~/.virtualenvs/hype/lib/python3.6/site-packages/pywxclient/core/api.py in wrapper(cls, *args, **kwargs)
     36                     raise SessionExpiredError
     37 
---> 38                 raise APIResponseError
     39 
     40         return res

APIResponseError: 

I also run the threaded example, same error there. I can receive and read the incoming messages with it, though.

Is there example to send image messages?

I couldn't find an example to send image message. For example, ImageMessage has a parameter media_id. Where to get this media_id?

It'll be very helpful to have an example in this case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.