Python Fetion

Python November 5th, 2008

项目地址在: http://git.lazytech.info/?p=python-fetion.git

首先感谢 nathan’s space 的飞信协议分析以及 open fetionfetion protocol plugin for pidgin 这两个项目的代码对我的启发 :)

介绍:
fetion.py 是飞信 HTTP 的实现, 可以获得好友列表和发送短信
twisted-fetion 下的 fetionclient.py 是飞信的 TCP socket 的实现, 可以用来收发短信, 支持外部程序通过 HTTP POST 的方式来发送短信

fetion.py 的使用:

1
python fetion.py -m 159xxxxxxxx -t "sip:XXXXXXXXX@fetion.com.cn;p=XXX" -b "hello world"

fetionclient.py 的使用:

1
python fetionclient.py -m 159xxxxxxxx

启动服务器之后, 可以通过 curl 来发起个 HTTP POST 的请求来发送短信, 或者是直接访问 http://localhost:8765 通过 Web 界面来发送

1
2
# the to and body parameters should be quoted
curl -d "to=sip%3AXXXXXXXXX%40fetion.com.cn%3Bp%3DXXXX&body=hello%20world" "http://localhost:8765"

项目的起由是因为小员一直想要个服务器状态短信通知的程序, 短信网关没钱买, 只好打飞信的主意了… 刚好最近公司的项目结了, 有时间可以挥霍, 闲得蛋疼就开始动手了. 一开始我先把 PHP 的 open fetion 调通, 然后小员把它翻译成了 python 的版本, 最后我再整了个基于 twisted 的版本出来.

目前项目是满足了我们的所有需求了, 所以版本也许会一直停留 0.1 上, 如果不继续蛋疼的话…

Related posts:

  1. Python 和验证码
  2. Python解析验证码

Tags: ,



Reader's Comments

  1. amerika TURKEY Windows XP Mozilla Firefox 3.0.4 | November 14th, 2008 at 9:21 pm

    Is there any information about this subject in other languages?

    Reply to this comment
  2. Duo CHINA Windows XP Mozilla Firefox 3.0.3 | November 14th, 2008 at 9:51 pm

    This is for Chinese mobile user, so wrote in Chinese only :)

    Reply to this comment
  3. kukat SINGAPORE PHP | February 13th, 2009 at 1:07 am

    能否说明下接收短信的原理?最好是php的实现,python看不打懂啊…

    Reply to this comment
  4. gohsy CHINA Windows Server 2003 Mozilla Firefox 3.0.8 | April 17th, 2009 at 4:30 am

    测试过了,看了nathan的文章才知道什么是sip:xxx;p=xxx中的p值是什么意思了,虽然测试成功,但这个发送带来了麻烦。

    老兄,进一步完善一下,fetion.py的传入参数中变成“-t 手机号”多好啊!

    Reply to this comment
  5. Duo CHINA Windows XP Mozilla Firefox 3.0.8 | April 17th, 2009 at 9:44 am

    你可以去试试取 git 仓库里的 fetion.py, 那时候加了发送到手机号的支持的.
    原理就是先取联系人的信息, 获得手机号码的列表, 但如果对方隐藏了手机号就没辙了…

    Reply to this comment
  6. loki NETHERLANDS Windows XP Internet Explorer 7.0 | June 6th, 2009 at 6:15 am

    你的蛋什么时候不疼过

    Reply to this comment
  7. 改良的 fetion.py UNITED STATES WordPress 2.8 | July 6th, 2009 at 3:47 pm

    [...] 这个 fetion.py 来自 这里。 [...]

    Reply to this comment
  8. brightman CHINA Windows XP Mozilla Firefox 3.5.3 | September 22nd, 2009 at 4:48 pm

    好像有问题,发送不了短信。
    SIP-C/2.0 400 Bad Request\r\nI: 2\r\nQ: 9 R\r\n\r\n

    Reply to this comment
  9. Brooklyn CHINA Linux Mozilla Firefox 3.5.3 | October 13th, 2009 at 7:26 am

    几番幸苦的查找,发现源地址在这里。楼主,我转载收藏一下,哈。

    Reply to this comment
  10. 谋定而后动 » python-fetion SINGAPORE WordPress 2.8.4 | October 13th, 2009 at 7:32 am

    [...] 发现一篇强文,先弄个链接,有时间DIY一下,嘿嘿。 源文:http://blog.lazytech.info/2008/11/05/python-fetion/ [...]

    Reply to this comment

Leave a Comment