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

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

 

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

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

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

  程序在线演示在这里: http://www.williamlong.info/twitter/

  全部源程序代码如下: 

XML/HTML代码
  1. <%@ CODEPAGE=65001 %>  
  2.   
  3. <%   
  4. If Request("submit")<>"" Then   
  5.   
  6.  Dim xmlhttp   
  7.  Set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")   
  8.   
  9.  Response.Cookies("save_username")=Request("username")   
  10.  Response.Cookies("save_username").Expires=Date+365   
  11.  Response.Cookies("save_password")=Request("password")   
  12.  Response.Cookies("save_password").Expires=Date+365   
  13.  username = Request("username")   
  14.  password = Request("password")   
  15.   
  16.  post_status = "status=" + server.URLencode(Request("updateStatus"))   
  17.   
  18.  If Request("twitter") = 1 Then   
  19.   xmlhttp.Open "POST", "http://" & username & ":" & password & "@twitter.com/statuses/update.xml", False   
  20.   xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"   
  21.   xmlhttp.setRequestHeader "Content-Length", Len(post_status)   
  22.   xmlhttp.Send (post_status)   
  23.   Response.Write "twitter OK." 'xmlhttp.responseText    
  24.  End If   
  25.     
  26.  If Request("fanfou") = 1 Then   
  27.   xmlhttp.Open "POST", "http://" & username & ":" & password & "@api.fanfou.com/statuses/update.xml", False   
  28.   xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"   
  29.   xmlhttp.setRequestHeader "Content-Length", Len(post_status)   
  30.   xmlhttp.Send (post_status)   
  31.   Response.Write "fanfou OK." 'xmlhttp.responseText    
  32.  End If   
  33.   
  34.  If Request("digu") = 1 Then   
  35.   post_status = "content=" + server.URLencode(Request("updateStatus"))   
  36.   xmlhttp.Open "POST", "http://" & username & ":" & password & "@api.digu.com/statuses/update.xml", False   
  37.   xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"   
  38.   xmlhttp.setRequestHeader "Content-Length", Len(post_status)   
  39.   xmlhttp.Send (post_status)   
  40.   Response.Write "digu OK." 'xmlhttp.responseText    
  41.  End If   
  42.   
  43.  If Request("zuosa") = 1 Then   
  44.   xmlhttp.Open "POST", "http://" & username & ":" & password & "@api.zuosa.com/statuses/update.xml", False   
  45.   xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"   
  46.   xmlhttp.setRequestHeader "Content-Length", Len(post_status)   
  47.   xmlhttp.Send (post_status)   
  48.   Response.Write "zuosa OK." 'xmlhttp.responseText    
  49.  End If   
  50.   
  51.  Set xmlhttp = Nothing    
  52.  response.end   
  53. Else   
  54.   
  55. %>  
  56.   
  57. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">  
  58. <html>  
  59. <head>  
  60.  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>  
  61.  <meta http-equiv="Content-Language" content="zh-CN" />  
  62.  <title>更新状态</title>  
  63. <script language="javascript">     
  64. function countChar(textareaName,spanName)   
  65. {     
  66.  document.getElementById(spanName).innerHTML = 140 - document.getElementById(textareaName).value.length;   
  67. }     
  68. </script>  
  69. </head>  
  70. <body>  
  71.  <form method="post" action="<%= Request.ServerVariables("URL")%>">  
  72.   <p>  
  73.    <textarea tabindex="1" id="updateStatus"  name="updateStatus" rows="6" cols="40" onkeydown='countChar("updateStatus","counter");' onkeyup='countChar("updateStatus","counter");'></textarea>  
  74.   </p>  
  75.   <p>  
  76.    <label><input tabindex="2" type="submit" id="submit" name="submit" value="  发     布  " /></label>    可以输入 <span id="counter">140</span> 字   
  77.   </p>  
  78.   <p>  
  79.    <label>用户名:</label>  
  80.    <input tabindex="3" type="text" name="username" id="username" value="<%= Request.Cookies("save_username")%>" />  
  81.   </p>  
  82.   <p>  
  83.    <label>密 码:</label>  
  84.    <input tabindex="4" type="password" name="password" id="password" value="<%= Request.Cookies("save_password")%>" />  
  85.   </p>  
  86.   <p>  
  87.    <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>  
  88.   </p>  
  89.  </form>  
  90. </body>  
  91. </html>  
  92.   
  93. <%   
  94. End if   
  95. %>  
  96.     
;


文章出自 原创文章转载请留出处 http://www.918x.com/index.php


添加收藏: Bookmark and Share

« 上一篇 | 下一篇 »

只显示10条记录相关文章

发表评论

评论内容 (必填):