Posts Tagged mblog

twitter,sina,renren同时

  1. #!/bin/bash
  2. LOGFILE=/path/for/log/file
  3. CURL=/usr/bin/curl
  4. SINACOOKIE=/tmp/sina.cookie
  5. RRCOOKIE=/tmp/renren.cookie
  6. SINAUSER=sina microblog username
  7. SINAPASS=sina microblog password
  8. RRUSER=renren.com username
  9. RRPASS=renren.com password
  10. TWUSER=twitter username
  11. TWPASS=twitter password
  12.  
  13. STATUS=$1
  14. SWITCH=$2
  15.  
  16. update_sina()
  17. {
  18.     ${CURL} -d "service=miniblog&entry=miniblog&username=${SINAUSER}&password=${SINAPASS}&url=http://t.sina.com.cn/ajaxlogin.php"  "http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.3.0)" -e "http://t.sina.com.cn/" -c ${SINACOOKIE} -s >> /dev/null
  19.     RESPONSE=`${CURL} -d "content=${STATUS}&pic=&from=myprofile" "http://t.sina.com.cn/mblog/publish.php" -e "http://t.sina.com.cn/jinuljt" -b ${SINACOOKIE} -s`
  20.         RESULT="t.sina.com.cn "
  21.         if echo ${RESPONSE}|grep -q "data"
  22.         then
  23.                 RESULT+="succ"
  24.         else
  25.                 RESULT+="fail"
  26.         fi
  27.         echo ${RESULT}|tee -a ${LOGFILE}
  28. }
  29.  
  30. update_rr()
  31. {
  32.         ${CURL} -d "email=${RRUSER}&password=${RRPASS}&origURL=http://www.renren.com/Home.do&domain=renren.com"   "http://passport.renren.com/PLogin.do" -c ${RRCOOKIE} -L -s  >> /dev/null
  33.         RESPONSE=`${CURL} -d "c=${STATUS}&raw=${STATUS}&isAtHome=1" "http://status.renren.com/doing/update.do?" -e "http://status.renren.com/ajaxproxy.htm"  -b ${RRCOOKIE} -L -s`
  34. #echo ${RESPONSE}
  35.         RESULT="renren.com "
  36.         if echo ${RESPONSE}|grep -q "updateStatusId"
  37.         then
  38.                 RESULT+="succ"
  39.         else
  40.                 RESULT+="fail"
  41.         fi
  42.         echo ${RESULT}|tee -a ${LOGFILE}
  43. }
  44.  
  45. update_twitter()
  46. {
  47.         RESPONSE=`${CURL} -u "${TWUSER}:${TWPASS}" -d status="${STATUS}" https://twitter.com/statuses/update.xml -s`
  48. #echo ${RESPONSE}
  49.         RESULT="twitter "
  50.         if echo ${RESPONSE}|grep -q "status"
  51.         then
  52.                 RESULT+="succ"
  53.         else
  54.                 RESULT+="fail"
  55.         fi
  56.         echo ${RESULT}|tee -a ${LOGFILE}
  57. }
  58.  
  59. echo `date +"%F %H:%M:%S"` >> ${LOGFILE}
  60. echo ${STATUS} >> ${LOGFILE}
  61.  
  62. if [ -z ${SWITCH} ]
  63. then
  64.    update_twitter
  65.    update_rr
  66.    update_sina
  67. fi
  68.  
  69.  
  70. if echo ${SWITCH}|grep -q "r"
  71. then
  72.    update_rr
  73. fi
  74.  
  75. if echo ${SWITCH}|grep -q "t"
  76. then
  77.         update_twitter
  78. fi
  79.  
  80. if  echo ${SWITCH}|grep -q "s"
  81. then
  82.         update_sina
  83. fi
  84.  
  85. echo "" >> ${LOGFILE}

renren对post内容有修改了,需要post中有一个domain用来重定向,否则登录失败。
增加了sina microblog的支持。其实都很简单,就是用wireshark分析了他们的http交互。

以上只要修改用户名和密码就可以了。可以通过“rts”三个字符的出现于否来控制提交到哪几个网站。

No Comments

gtalk robot

最近在使用一python 的gtalk robot
不错,配合上我的twitter,sina,renren同步update的脚本。

我的手机gtalk一直在线。所以只要往我的robot按照我设定的格式发送一条,就能自动update了。

该机器人,可以定义n多自己的命令。不是一般的酷。

,

No Comments

新浪微博使用curl

  1. SINAUSER=username
  2. SINAPASS=password
  3. SINACOOKIE=/path/store/sina/cookie
  4. curl -d "service=miniblog&entry=miniblog&username=${SINAUSER}&password=${SINAPASS}&url=http://t.sina.com.cn/ajaxlogin.php"  "http://login.sina.com.cn/sso/login.php?client=ssologin.js(v1.3.0)" -e "http://t.sina.com.cn/" -c ${SINACOOKIE} -s >> /dev/null
  5.  curl -d "content=${STATUS}&pic=&from=myprofile" "http://t.sina.com.cn/mblog/publish.php" -e "http://t.sina.com.cn/jinuljt" -b ${SINACOOKIE}

,

No Comments