글 수 8
Excel을 이용해서 Twitter에 DM을 보내는 소스입니다.
현재는 특별히 활용할 계획이 없어서..
일단 연구과제로 등록합니다.
** 현재는 트위터 정책이 바뀌어서 Basic Auth는 작동이 안된다고 합니다.
해당 소스는 Basic Auth기반이라 현재는 사용이 불가하다고 합니다.
그래도 참고해볼만한 소스이긴 하지요..
출처 : http://xguru.net/547
파일 작성자(저작권자) : 구루님
파일 다운로드 : Twitter MultiDM.xls
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Function DM(touser, tweetmsg, uid, pwd) Dim objHTTP As Object Set objHTTP = CreateObject("Microsoft.XMLHTTP") objHTTP.Open "POST", "http://twitter.com/direct_messages/new.xml", False, uid, pwd objHTTP.send "user=" & touser & "&text=" & tweetmsg DM = objHTTP.responseText Set objHTTP = Nothing End Function Function getStringBetween(str, sstart, send) PosStart = InStr(str, sstart) PosEnd = InStr(str, send) If (PosStart > 0) And (PosEnd > 0) Then getStringBetween = Mid(str, PosStart + Len(sstart), PosEnd - PosStart - Len(sstart)) Else getStringBetween = "" End If End Function Function Send_DM() Load frmLogin frmLogin.Show strUID = frmLogin.txtUID strPWD = frmLogin.txtPWD Unload frmLogin If Len(strUID) = 0 Or Len(strPWD) = 0 Then Exit Function ' Twitter Limits 250 DM per day. You can't exceed this Application.Cursor = xlWait For i = 2 To 151 TweetID = Cells(i, 1) If Len(Cells(i, 2)) > 0 Then tweetmsg = Cells(i, 2) End If If Len(TweetID) > 0 Then res = DM(TweetID, tweetmsg, strUID, strPWD) Cells(i, 5) = res If (Len(getStringBetween(res, "id", "/id")) > 0) Then Cells(i, 3) = "성공" Else Cells(i, 3) = "실패" End If Else Exit For End If ' 혹시 몰라서 한건의 DM당 1초씩 딜레이를 뒀습니다. 트위터 서버측에 부하를 줄이기 위함입니다. ' 시간이 문제가 안되시는분은 5000 정도로 해서 5초 딜레이를 주시면 전혀 무리없을듯 합니다. Sleep 1000 Next i Application.Cursor = xlDefault End Function |