青青子衿, 悠悠我心, 但为君故, 沉吟至今
« 在JavaScript中实现统计文本框Textarea字数利用U盘进行软件加密的方法 »

同时更新Twitter、饭否、嘀咕和做啥

  很多微博客(如嘀咕和做啥)和第三方工具(如Hellotxt、Ping.fm)都同时提供了同步到其他微博客的服务,可以同步信息到一些主要的微博客服务,如Twitter、饭否等,但是这些工具都有一个很重要的问题,就是存在密码被盗或泄漏的风险。

  目前大多数微博客是通过用户名和密码做为参数进行认证登录,Twitter可使用OAuth协议进行认证,而这些用户名和密码存放在这些同步工具网站上,万一保存不当,就有可能会被黑客获取,带来用户帐号被盗的风险,因此,比较保险的办法是通过自己写的程序来实现微博客的自动同步功能,这样被黑客破解的可能性就小了很多。

  我这里写了一个同时更新Twitter、饭否、嘀咕和做啥等微博客的小程序,可以在自己的服务器上实现微博客同时更新功能,为了代码简单,使用时需要这几个服务使用相同的用户名和相同的密码,选中需要同步的微博客,也可勾选掉不想发布的服务,然后输入用户名和密码,发布信息后就会自动同时更新这几个微博客。

  全部源程序代码如下:

<%@ CODEPAGE=65001 %>

<%
If Request("submit")<>"" Then

 Dim xmlhttp
 Set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")

 Response.Cookies("save_username")=Request("username")
 Response.Cookies("save_username").Expires=Date+365
 Response.Cookies("save_password")=Request("password")
 Response.Cookies("save_password").Expires=Date+365
 username = Request("username")
 password = Request("password")

 post_status = "status=" + server.URLencode(Request("updateStatus"))

 If Request("twitter") = 1 Then
  xmlhttp.Open "POST", "http://" & username & ":" & password & "@twitter.com/statuses/update.xml", False
  xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
  xmlhttp.setRequestHeader "Content-Length", Len(post_status)
  xmlhttp.Send (post_status)
  Response.Write "twitter OK." 'xmlhttp.responseText
 End If
 
 If Request("fanfou") = 1 Then
  xmlhttp.Open "POST", "http://" & username & ":" & password & "@api.fanfou.com/statuses/update.xml", False
  xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
  xmlhttp.setRequestHeader "Content-Length", Len(post_status)
  xmlhttp.Send (post_status)
  Response.Write "fanfou OK." 'xmlhttp.responseText
 End If

 If Request("digu") = 1 Then
  post_status = "content=" + server.URLencode(Request("updateStatus"))
  xmlhttp.Open "POST", "http://" & username & ":" & password & "@api.digu.com/statuses/update.xml", False
  xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
  xmlhttp.setRequestHeader "Content-Length", Len(post_status)
  xmlhttp.Send (post_status)
  Response.Write "digu OK." 'xmlhttp.responseText
 End If

 If Request("zuosa") = 1 Then
  xmlhttp.Open "POST", "http://" & username & ":" & password & "@api.zuosa.com/statuses/update.xml", False
  xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"
  xmlhttp.setRequestHeader "Content-Length", Len(post_status)
  xmlhttp.Send (post_status)
  Response.Write "zuosa OK." 'xmlhttp.responseText
 End If

 Set xmlhttp = Nothing
 response.end
Else

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 <meta http-equiv="Content-Language" content="zh-CN" />
 <title>更新状态</title>
<script language="javascript"> 
function countChar(textareaName,spanName)

 document.getElementById(spanName).innerHTML = 140 - document.getElementById(textareaName).value.length;

</script>
</head>
<body>
 <form method="post" action="<%= Request.ServerVariables("URL")%>">
  <p>
   <textarea tabindex="1" id="updateStatus"  name="updateStatus" rows="6" cols="40" onkeydown='countChar("updateStatus","counter");' onkeyup='countChar("updateStatus","counter");'></textarea>
  </p>
  <p>
   <label><input tabindex="2" type="submit" id="submit" name="submit" value="  发     布  " /></label>    可以输入 <span id="counter">140</span> 字
  </p>
  <p>
   <label>用户名:</label>
   <input tabindex="3" type="text" name="username" id="username" value="<%= Request.Cookies("save_username")%>" />
  </p>
  <p>
   <label>密 码:</label>
   <input tabindex="4" type="password" name="password" id="password" value="<%= Request.Cookies("save_password")%>" />
  </p>
  <p>
   <label><input type="checkbox" id="twitter" name="twitter" value="1" checked="checked"> Twitter </label><label><input type="checkbox" id="fanfou" name="fanfou" value="1" checked="checked"> 饭否 </label><label><input type="checkbox" id="digu" name="digu" value="1" checked="checked"> 嘀咕 </label><label><input type="checkbox" id="zuosa" name="zuosa" value="1" checked="checked"> 做啥</label>
  </p>
 </form>
</body>
</html>

<%
End if
%>
 



原创文章如转载,请注明:转载自月光博客 [ http://www.williamlong.info/ ]

本文链接地址:http://www.williamlong.info/archives/1831.html
  • 文章排行:
  • 1.kate
  • 沙发
    第一次
    wordpress教程网 于 2009-6-16 22:46:35 回复
    不用这么复杂吧。
    wordpress教程网 于 2009-6-16 22:47:28 回复
    不用这么复杂吧。...
    零八后 于 2009-6-18 23:27:54 回复
    听说,这样回复,就可以排在前面。
    XDash 于 2009-6-22 17:49:44 回复
    正需要开发API的资料呢。谢谢。
  • ip: 219.234.81.*  2009-6-15 23:51:14   回复
  • 2.evilguy
  • 慢了。。没拿到沙发。。。

    日志的代码部分在chrome下显示错位了。。。

    xmlhttp.Send (post_status) 之后 根据服务器返回的信息 判断是否OK。。因为输入的账号密码有可能出错,此时再显示OK就不现实了。
  • ip: 115.194.116.*  2009-6-16 0:12:56   回复
  • 3.我想想
  • 一看这代码就熟悉啊,可爱可亲的asp
    好像现在过时啊
  • ip: 218.64.197.*  2009-6-16 0:26:09   回复
  • 4.我想想
  • 真的不错啊,太有才了。
  • ip: 218.64.197.*  2009-6-16 0:27:11   回复
  • 5.风雪残士
  • 这个好 方便 前排坐 o(∩_∩)o...
  • ip: 60.190.93.*  2009-6-16 0:27:31   回复
  • 6.wenshi0295
  • 很好啊,你的博客一直在关注
  • ip: 58.248.68.*  2009-6-16 0:30:34   回复
  • 8.受不了
  • 他们的API居然都是一个格式,受不了
    球球快跑 于 2009-6-16 1:18:55 回复
    为了规范。
  • ip: 61.153.123.*  2009-6-16 0:36:45   回复
  • 10.天然卷
  • 不错,自己再加了个叽歪
    fd 于 2009-6-16 12:26:18 回复
    怎么加的叽歪
  • ip: 125.66.13.*  2009-6-16 1:23:46   回复
  • 11.神兽
  • 一直需要这样的东西XXOO
  • ip: 122.96.228.*  2009-6-16 3:34:52   回复
  • 12.dotion
  • 有没有PHP版本的???
    williamlong 于 2009-6-16 9:11:38 回复
    可以参照这个修改为PHP的,应该很简单的。
  • ip: 119.145.5.*  2009-6-16 7:41:29   回复
  • 13.鬓角之家
  • 月光博客之所以能成为名博,最主要的就是它的主人除了有一点正义感外,还是一个无私的人,在他这里,总能找到你想要的,或是你想知道的。
    therock 于 2009-12-30 10:00:34 回复
    处理 URL 时服务器出错。请与系统管理员联系。

    这个是不是服务器超时所致?
  • ip: 219.137.203.*  2009-6-16 8:06:20   回复
  • 14.园子
  • 同意13楼的说法

    只是一个人申请那么多我想想都有感觉累

    嘿嘿~
  • ip: 123.6.100.*  2009-6-16 8:59:56   回复
  • 15.angnow
  • 学习了,谢谢月光.
  • ip: 61.141.250.*  2009-6-16 9:24:10   回复
  • 17.明月本无心
  • 可以同时更新的网站少了点,可以多些吗?特别是给“墙”了的网站。
  • ip: 203.208.60.*  2009-6-16 11:17:04   回复
  • 18.猪头
  • 我正在做php的程序,功能和这个类似,不过我希望能显示各个微博的status
  • ip: 61.50.136.*  2009-6-16 12:25:51   回复
  • 19.牵手
  • 试用了一下,同步到嘀咕成功,饭否却无端多出来一条不知道是谁写的状态,做啥没有成功!
  • ip: 123.170.75.*  2009-6-16 12:53:26   回复
  • 20.grnnet
  • 去试试看啊,太好了呀
  • ip: 121.20.41.*  2009-6-16 13:38:57   回复
  • 21.大漠
  • 越来越欣赏你了
  • ip: 60.181.197.*  2009-6-16 14:27:00   回复
  • 22.布股鸟
  • 很好很强大,不过自己还没用过什么微博客呢!好像落伍了啊~
  • ip: 202.118.102.*  2009-6-16 14:28:20   回复
  • 24.XjAcKs
  • 自己的服务器?那可是有钱人干的事……
  • ip: 60.23.248.*  2009-6-16 17:09:47   回复
  • 25.2547
  • 这个不错哦。。。
  • ip: 124.73.42.*  2009-6-16 20:03:15   回复
  • 26.tty
  • 这个密码会被主机商看到,傻比...
    williamlong 于 2009-6-17 12:20:22 回复
    你仔细看看程序就应该知道密码是保存在用户本地cookies里的。
  • ip: 119.145.5.*  2009-6-16 22:31:20   回复
  • 27.大帝007
  • 加一个嘀咕和饭否的机器人,应该问题都能解决吧,呵呵
  • ip: 123.60.89.*  2009-6-17 0:51:30   回复
  • 28.kid
  • 如何解决twitter API数目的限制?
    抓包后模拟POST没成功...
    williamlong 于 2009-6-17 12:19:24 回复
    twitter API数目的限制在服务器端没法解决,就是每小时100次,除非用客户端软件来解决。
  • ip: 119.145.5.*  2009-6-17 11:12:32   回复
  • 29.炎龙博客
  • 有没有开发个zblog的插件啊?
    这样每次都手动提交很不方便。
  • ip: 58.59.26.*  2009-6-17 15:47:13   回复
  • 30.apturic
  • 不会用…… 完全不懂代码的人……
  • ip: 61.161.67.*  2009-6-18 7:31:29   回复
  • 31.koukang
  • 莫名其妙出现一条非自发消息sfdsf。。。
    谁的恶作剧。。。
  • ip: 219.137.138.*  2009-6-19 15:51:33   回复
  • 32.fff
  • msxml3.dll 错误 '80070005'

    拒绝访问。

    /twitter/index.asp,行 22
  • ip: 119.131.69.*  2009-6-21 18:51:31   回复
  • 33.west
  • 1.不同的网站用户名和密码不同是不是不能用?
    2.已经在twitter里发了的可以转到jiwai去吗?
  • ip: 118.249.110.*  2009-6-25 0:19:18   回复
  • 34.asdasdas
  • 腾讯公司电话号码是什么:(08)98677-88889
  • ip: 59.50.169.*  2009-6-25 0:24:39   回复
  • 35.一品茶
  • 牛人!!!!!!!!!
  • ip: 116.112.74.*  2009-6-28 3:57:44   回复
  • 36.tony
  • 做啥的更新不起作用,请博主查实
  • ip: 125.119.14.*  2009-6-30 10:27:19   回复
  • 37.zare
  • Twitter的新应用!
    现在可以通过revtwt向22908254Twitter的追随者发布广告!
    号称最大的社会会话广告联播网!
    http://revtwt.com/index.php?id=24798
  • ip: 59.55.154.*  2009-7-4 17:49:27   回复
  • 38.lu
  • 能同时搜索吗?弟兄们给推荐个搜索 微博客的
  • ip: 117.32.156.*  2009-7-5 12:31:42   回复
  • 40.yihui
  • 牛人,只能说很欣赏。。。
  • ip: 119.139.83.*  2009-7-14 13:15:38   回复
  • 42.河蟹
  • 全部河蟹,没商量
  • ip: 119.181.4.*  2009-7-24 5:15:51   回复

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

订阅博客

  • 订阅我的博客:订阅我的博客
  • 跟随新浪微博:跟随新浪微博
  • 通过Google订阅本站
  • 通过鲜果订阅本站
  • 通过电子邮件订阅本站

站内搜索

热文排行

最新评论及回复

最近发表

网站收藏

本站采用创作共用版权协议, 要求署名、非商业用途和保持一致. 转载本站内容必须也遵循“署名-非商业用途-保持一致”的创作共用协议.
This site is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.