curl-library
Re: Multiple post fields VB
Date: Mon, 21 Jun 2010 16:28:13 -0700
On Mon, Jun 21, 2010 at 07:00:25PM -0400, Perkins, Christopher J wrote:
> I have written code that will work through the command line interface, but when
> I run it through vb i get to the page, however, I get a system error message
> from the website itself. I know that I am getting to the page ok, but for some
> reason it does not like my post data. Here is a sample of the command line
> code, followed by the vb sample. Can anyone see any issues with this? Any help
> would be greatly appreciated!
[...]
> vbcurl_easy_setopt context, CURLOPT_POSTFIELDS, "RecipID=" & RecipID
> vbcurl_easy_setopt context, CURLOPT_POSTFIELDS, "RecipDOB=" & RecipDOB
> vbcurl_easy_setopt context, CURLOPT_POSTFIELDS, "RecipDOI=" & RecipDOI
> vbcurl_easy_setopt context, CURLOPT_POSTFIELDS, "RecipDOS=" & RecipDOS
> vbcurl_easy_setopt context, CURLOPT_POSTFIELDS, "Submit=SUBMIT"
> vbcurl_easy_setopt context, CURLOPT_POSTFIELDS, "UserID=ABCDEF"
> vbcurl_easy_setopt context, CURLOPT_POSTFIELDS, "UserPW=12345"
I don't know about the VB binding, but the C binding doc says
CURLOPT_POSTFIELDS "should be the full data to post". You can't concatenate
data strings with multiple calls this way.
> 'Below tried to post fields all together based on instructions online,
> didn't work.
> ' vbcurl_easy_setopt context, CURLOPT_POSTFIELDS, "RecipID=" & RecipID &
> "RecipDOI=" & RecipDOI & "RecipDOS=" & RecipDOS & "Submit=SUBMIT&UserID=ABCDEF&
> UserPW=12345"
This is on the right track, but you're missing some literal "&" characters.
There's one there before UserID and UserPW, but missing before the others.
> ' vbcurl_easy_setopt context, CURLOPT_POST, 1
> vbcurl_easy_setopt context, CURLOPT_COOKIE, "UserID=ABCDEF; UserPW=12345;
> LastTime=" & urlencode(CStr(Date & " " & Time)) & "; OwnerNum=01"
Synthesizing your own cookies seems problematic. If the remote site ever
changes this, your code will break. Better would be to do a GET or other
operation to receive the cookie ahead of time.
>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-06-22