Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to post a reply to a forum in VB ?

Posted on 2006-04-19
9
Medium Priority
?
243 Views
Last Modified: 2010-04-07
I created this code to post a reply to a forum (I'm testing in IPB) with Visual Basic but when I test , it worked in my localhost , but it not work with other sites and forums .

[CODE]
---------------------------------------------------------------
Private Sub Form_Load()
With Winsock1
    .Close
    .Connect "testing.com", 80
End With
Private Sub Form_Load()
---------------------------------------------------------------
Private Sub Winsock1_Connect()
Dim strDataToSend As String

strDataToSend = "POST /index.php? HTTP/1.1" & vbCrLf
strDataToSend = strDataToSend & "Host: testing.com" & vbCrLf
strDataToSend = strDataToSend & "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1" & vbCrLf
strDataToSend = strDataToSend & "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" & vbCrLf
strDataToSend = strDataToSend & "Accept-Language: en-us,en;q=0.5" & vbCrLf
strDataToSend = strDataToSend & "Accept-Encoding: gzip,deflate" & vbCrLf
strDataToSend = strDataToSend & "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" & vbCrLf
strDataToSend = strDataToSend & "Keep-Alive: 300" & vbCrLf
strDataToSend = strDataToSend & "Connection: keep-alive" & vbCrLf
strDataToSend = strDataToSend & "Cookie: member_id=1; pass_hash=91ce85d7197b57a7d3bef570f2ea4d26;" & vbCrLf
strDataToSend = strDataToSend & "Content-Type: application/x-www-form-urlencoded" & vbCrLf
strDataToSend = strDataToSend & "Content-Length: 81" & vbCrLf
strDataToSend = strDataToSend & "act=Post&CODE=03&f=19&t=57&auth_key=4eaac715c8c2ef9c057290f728590239&Post=testing" & vbCrLf
strDataToSend = strDataToSend & vbCrLf

Winsock1.SendData strDataToSend
End Sub
--------------------------------------------End of CODE-------------------------------

thanx for ur help
0
Comment
Question by:ktsm1809
6 Comments
 
LVL 5

Accepted Solution

by:
AtanAsfaloth earned 1000 total points
ID: 16489292
I'm not sure about this, but shouldn't there be a blank line between the headers and the data? (in this case the 'form' values)
Shouldn't this line:

strDataToSend = strDataToSend & "Content-Length: 81" & vbCrLf

be changed to:

strDataToSend = strDataToSend & "Content-Length: 81" & vbCrLf & vbcrlf

And can you elaborate what you mean by 'it worked in my localhost , but it not work with other sites and forums'

Atan Asfaloth
0
 
LVL 8

Expert Comment

by:Leo Eikelman
ID: 16489628
you are hardcoding the host are u not?

strDataToSend = strDataToSend & "Host: testing.com" & vbCrLf

would you not have to change this every time you change location?


Leo
0
 

Author Comment

by:ktsm1809
ID: 16495272
[quote]

be changed to:

strDataToSend = strDataToSend & "Content-Length: 81" & vbCrLf & vbcrlf


wow , thanx so much . it work now (a small but important error :D)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:AtanAsfaloth
ID: 16505275
You're welcome:)
0
 
LVL 5

Expert Comment

by:AtanAsfaloth
ID: 16677017
As vain as this sounds, I reccommend my own post to be accepted, since ktsm1809 quoted my solution and said it worked...
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 16729864
AtanAsfaloth,
It is not at all vain to point out that you are right when you are, in fact, right :-).  I appreciate it when an Expert takes the time to recheck these old questions.  Thanks!
-- DanRollins, EE Cleanup Volunteer
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question