存档

文章标签 ‘嘀咕’

一段同时更新Twitter、饭否、嘀咕和做啥的asp代码

2009年6月16日 风雪残士 没有评论

多微博客(如嘀咕和做啥)和第三方工具(如Hellotxt、Ping.fm)都同时提供了同步到其他微博客的服务,可以同步信息到一些主要的微博客服务,如Twitter、饭否等,但是这些工具都有一个很重要的问题,就是存在密码被盗或泄漏的风险。
  目前大多数微博客是通过用户名和密码做为参数进行认证登录,Twitter可使用OAuth协议进行认证,而这些用户名和密码存放在这些同步工具网站上,万一保存不当,就有可能会被黑客获取,带来用户帐号被盗的风险,因此,比较保险的办法是通过自己写的程序来实现微博客的自动同步功能,这样被黑客破解的可能性就小了很多。
  这里写了一个同时更新Twitter、饭否、嘀咕和做啥等微博客的小程序,可以在自己的服务器上实现微博客同时更新功能,为了代码简单,使用时需要这几个服务使用相同的用户名和相同的密码,选中需要同步的微博客,也可勾选掉不想发布的服务,然后输入用户名和密码,发布信息后就会自动同时更新这几个微博客。
  程序在线演示在这里: http://blog.tkbbs.com/twitter.asp
  全部源程序代码如下:
[code]<%@ 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
%>






">

    可以输入 140

" />

" />



<%
End if
%>[/code]
本文转载自:月光博客