kitykity's journal (kitykity) wrote in lj_dev,
kitykity's journal
kitykity
lj_dev

help with VB code

Hello all, Susan from MA. Mother of two kids <3, wife, and unix sysad.

Anyways, I'm learning VB, and was wondering if I could have someone help me out with some VB code. I'm trying to connect to LJ, post, and get a response. Very basic. But it hangs and I'm sure it's something simple I'm doing wrong.

Please don't *smack* me for being stupid, I'm only trying to learn... anyways, here's the code I've got if you want to have a look-see...


Private Sub cmdCancel_Click()
frmMain.staMain.Panels(1).Text = "LiveJournal: Post Cancelled.."
PostSock.Close
Me.Hide
txtEvent.Text = ""
End Sub

Private Sub cmdPost_Click()
If (txtEvent.Text <> "") Then
frmMain.staMain.Panels(1).Text = frmLogin.txtUsername.Text & " is connecting to Livejournal..."
cmdPost.Enabled = False
txtEvent.Enabled = False
PostSock.Connect "www.livejournal.com", 80
Else
MsgBox "You need to type text/nto post a message."
End If
End Sub

Private Sub PostSock_Connect()
frmMain.staMain.Panels(1).Text = "Posting to " & frmLogin.txtUsername.Text & "'s journal..."
CR = Chr(13)
NL = Chr(10)
PostSock.SendData "POST cgi-bin/log.cgi HTTP/1.0" & CR & NL
PostSock.SendData "Host: www.livejournal.com" & CR & NL
PostSock.SendData "Content-type: application/x-www-form-urlencoded" & CR & NL
PostSock.SendData "Content-length: 34"
PostSock.SendData "mode=login&user=" & frmLogin.txtUsername.Text & "&password=" & frmLogin.txtPassword.Text & CR & NL
PostSock.SendData "mode=postevent&user=" & frmLogin.txtUsername.Text & "&password=" & frmLogin.txtPassword.Text & "&event=" & txtEvent.Text
End Sub

Private Sub PostSock_DataArrival(ByVal bytesTotal As Long)
If (bytesTotal) Then
PostSock.GetData Data, vbString, bytesTotal
httpr = httpr & Data
frmStream.txtStream.Text = "LJ: " & Data & frmStream.txtStream.Text
End If
End Sub

Private Sub PostSock_Close()
PostSock.Close
cmdPost.Enabled = True
Dim X As New Collection
ParseResponse X, httpr
If (GetVal(X, "success") = "OK") Then
frmMain.staMain.Panels(1).Text = frmLogin.txtUsername.Text & "'s event was successfully posted."
frmPost.txtEvent.Text = ""
frmPost.txtEvent.Enabled = True
Else
MsgBox "Error updating journal." & Chr(10) & Chr(10) & GetVal(X, "errmsg")
frmMain.staMain.Panels(1).Text = GetVal(X, "errmsg")
End If
End Sub


Thanks in advance for being kind and taking a look...
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 9 comments