Code Monkey home page Code Monkey logo

pyfan's Introduction

pyfan

饭否客户端python版。

  • 更新说明:改用https,因为饭否的OAuth签名校验仍然使用http的URL计算,故用了一个HACK手段修改了requests_oauthlib(bug fixed)

安装

下载全部代码,运行:

pip install -r requirements.txt

配置

创建一个config.json的文件,加入申请的客户端ID:

{
    "CLIENT_KEY": "XXXX",
    "CLIENT_SECRET": "xxxx"
}

可选参数:

"PROXY":用于指定代理服务器,其值类似"http://localhost:8080"或"socks5://localhost:1080"

初始化

用户登录方式,运行登录用webserver:

python weblogin.py

浏览器打开: http://localhost:8880/ 将自动转向饭否授权页面,授权后返回显示登录用户名。登录成功以后相关的授权码会被保存在config.json中,之后即可退出webserver,开始使用本客户端。

使用

python
>> import pyfan
>> pyfan.timeline(count, page)
>> pyfan.mentions(count, page)
>> pyfan.usertimeline(user_id, count, page)
>> pyfan.showstatus(status_id or index)
>> pyfan.destroy(status_id or index)
>> pyfan.post(status[, photo])
>> pyfan.repost(status, index)
>> pyfan.reply(status, index)
>> pyfan.replyall(status, index)
>> pyfan.showcontext(index)
  • status_id和index通过类型自动判断
  • count为条数,默认为8,最大不超过60
  • page为页号,默认为0
  • user_id为用户ID,显示在用户名后面的括号中,字符串类型
  • status_id为消息ID,显示在时间后面的括号中,字符串类型
  • status为消息内容
  • photo为图片文件名,默认为空
  • index为消息编号,显示在最前在的方括号中,整数类型,注意:只能引用最近一次timeline/mentions/usertimelin/showstatus/showcontext调用结果。

命令行使用

(感谢令狐增加此功能)

python cli.py help            # 获得使用帮助
python cli.py                 # 获得timeline最新8条(默认值)信息
python cli.py mention 30      # 显示最新30条“提到我的”消息
python cli.py timeline 30 2   # 按每页30条计算,显示第二页timeline消息
python cli.py timeline page=2 # 按每页8条(默认值)计算,显示第二页timeline消息
python cli.py this is a demo  # 发送内容为“this is a demo”的消息
python cli.py "text=this is a demo" "photo=../photo/test.png"  
        # 发送内容为“this is a demo”的消息,并附带指定图片。注意图片后缀必需为png或jpg或gif。

pyfan's People

Contributors

ch-linghu avatar litomore avatar raptorz avatar stefanzweig avatar zhasm avatar

Stargazers

 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

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.