编程:模拟网页微博发布微博消息(twitter,腾讯微博,新浪微博,搜狐微博)

编程:模拟网页微博发布消息(twitter,腾讯微博,新浪微博,搜狐微博)

Programmatically post twitter (instant short messages) by simulating web requests/responses. (Sites: twitter.com, weibo.com, t.qq.com and t.sohu.com)

1. twitter

twitter登陆发布消息分析:

  1. 登陆页面:GET https://twitter.com/login
  2. 登陆请求:POST https://twitter.com/sessions
    1. POST Data: session%%5Busername_or_email%%5D=%s&session%%5Bpassword%%5D=%s&remember_me=1&scribe_log=&redirect_after_login=&authenticity_token=%s
  3. 更新网页:GET https://twitter.com/
  4. 发布消息:POST https://api.twitter.com/1/statuses/update.json
    1. POST Data: include_entities=true&status=%s&post_authenticity_token=%s

注1:%s为占位符

注2:twitter发布消息有限制(请参看:http://stackoverflow.com/questions/9510611/twitter-rate-limit)

演示程序:http://code.google.com/p/qidian-bobo/source/browse/src/cn/kk/qidianbobo/TwitterPublisher.java

  • 需要导出整个软件项目(svn checkout http://qidian-bobo.googlecode.com/svn/ qidian-bobo-read-only
  • 在TwitterPublisher里的main函数里修改用户名与密码

2. 腾讯微博

qq微博登陆发布消息分析:

  1. 登陆页面:GET http://t.qq.com/
  2. 用户验证:GET http://check.ptlogin2.qq.com/check?uin=%s&appid=46000101&ptlang=2052&r=%s
  3. 登陆请求:GET http://ptlogin2.qq.com/login?ptlang=2052&u=%s&p=%s&verifycode=%s&low_login_enable=1&low_login_hour=720&aid=46000101&u1=http%%3A%%2F%%2Ft.qq.com&ptredirect=1&h=1&from_ui=1&dumy=&fp=loginerroralert&action=3-42-26726&g=1&t=1&dummy=
  4. 发布消息:POST http://api.t.qq.com/old/publish.php
    1. POST Data: content=%s&startTime=%s&endTime=%s&countType=&viewModel=&attips=&pic=&apiType=8&syncQzone=0&syncQQSign=0

注1:%s为占位符

注2:qq密码验证的时候发送前经过散列算法加密

演示程序:http://code.google.com/p/qidian-bobo/source/browse/src/cn/kk/qidianbobo/QQPublisher.java

  • 需要导出整个软件项目(svn checkout http://qidian-bobo.googlecode.com/svn/ qidian-bobo-read-only
  • 在QQPublisher里的main函数里修改用户名与密码

3. 新浪微博

新浪微博登陆发布消息分析:

  1. 登陆页面:GET http://3g.sina.com.cn/prog/wapsite/sso/login.php?ns=1&revalid=2&backURL=http%3A%2F%2Fweibo.cn%2F&backTitle=%D0%C2%C0%CB%CE%A2%B2%A9&vt=
  2. 登陆请求:POST http://3g.sina.com.cn/prog/wapsite/sso/login_submit.php?rand=%s&backURL=http%3A%2F%2Fweibo.cn%2F&backTitle=%D0%C2%C0%CB%CE%A2%B2%A9&vt=4&revalid=2&ns=1

    1. POST Data:  mobile=%s&password_%s=%s&remember=on&backURL=http%%253A%%252F%%252Fweibo.cn%%252F&backTitle=%%E6%%96%%B0%%E6%%B5%%AA%%E5%%BE%%AE%%E5%%8D%%9A&vk=%s&submit=%%E7%%99%%BB%%E5%%BD%%95
  3. 发布消息:POST http://weibo.cn/mblog/sendmblog?st=
    1. POST Data: rl=0&content=%s

注1:%s为占位符

注2:这里是应用手机版新浪微博

演示程序:http://code.google.com/p/qidian-bobo/source/browse/src/cn/kk/qidianbobo/SinaPublisher.java

  • 需要导出整个软件项目(svn checkout http://qidian-bobo.googlecode.com/svn/ qidian-bobo-read-only
  • 在SinaPublisher里的main函数里修改用户名与密码

2. 搜狐微博

搜狐微博登陆发布消息分析:

  1. 登陆页面:GET http://w.sohu.com/t2/tologin.do?uname=&f_r=&fr=&passtype=1
  2. 登陆请求:POST http://w.sohu.com/t2/login.do
    1. POST Data:uname=%s&p=%s&saveLoginState=1&m=doLogin&f_r=&fr=
  3. 发布消息:POST http://w.sohu.com/t2/send.do?s_m_u=%s&suv=%s
    1. POST Data: content=%s&hiddenContent=&ru=.%%2Ffridoc.do&eru=.%%2Ffridoc.do&eruaction=fridoc&filter=&kw=&cc_key=wap_send_weibo&send=%%E5%%8F%%91%%E8%%A1%%A8

注1:%s为占位符

注2:应用搜狐微博手机版

演示程序:http://code.google.com/p/qidian-bobo/source/browse/src/cn/kk/qidianbobo/SohuPublisher.java

  • 需要导出整个软件项目(svn checkout http://qidian-bobo.googlecode.com/svn/ qidian-bobo-read-only
  • 在SohuPublisher里的main函数里修改用户名与密码