We help IT Professionals succeed at work.

TidHTTP.Post question...

Wim ten Brink
on
6,126 Views
Last Modified: 2008-07-26
Okay, i have this forum at http://www.workshop-alex.org/ which is quite uninteresting. It's just for experimental purposes anyway. You can have a look, even register but don't think it's a very reliable site...

Oh, well... I want to do something special with my own site. I want to auto-post messages in the 'Announcements' and the 'Jokes' groups. And I want to do this from a Delphi application! Thus I have a Delphi client and this client will first have to log on, maintain a cookie, go to the group and add a new topic to this group. Unfortunately, the amount of data I want to add in this new post could be too big to add on the URL of my site, thus I have to use the Post method to send the post to my server.

now, of course I could use a completely different technique, even include the post directly in the database on my server, but this is just a challenge for me. I want to do it this way and this way only. So, how do I get this to work? And I do want to use Indy for this...
Comment
Watch Question

VGR

Commented:
no problem, even using NMHTTP from D4

The only tricky part is to maintain the cookie.

I rather suggest you directly talk to the DB server - less challenging but more adapted to Delphi web applications IMHO
Wim ten BrinkSelf-employed developer
CERTIFIED EXPERT

Author

Commented:
Well, as you say... Talking to the DB server is just less of a challenge... And Indy has a nice component to maintain cookies which I've already played with. It works perfectly, allowing me to log in using the get method and specifying the parameters in the URL. But this doesn't work when the parameters are more than 10.000 characters...
So I have to find out how this post thingie works...
All-around developer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Wim ten BrinkSelf-employed developer
CERTIFIED EXPERT

Author

Commented:
@EddieShipman: Close enough for me! It works after a minor adjustment. Don't know where URLEncode comes from but doesn't matter. In the unit HTTPApp I found HTMLEncode() which seems to do the same. However, this led to:
  Params.WriteString(HTMLEncode('username=WorkshopAlex')+'&');
since I have to keep the '&' outside the encoding. Not a big thingie...

However, the magic word I needed was:
  IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
Which I had forgotten...

Btw... I just used:
  List := TStringList.Create;
  List.Text := IdHTTP1.Post('http://www.neopets.com/login.phtml', Params);
To get the page inside a stringlist. That works just as well as using that stream method you used. :-)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.