login about faq

i am trying to do a simple post... http://crg.ss-corp.com/live.asp?cid=1012&email=test@ss-corp.com&firstname=steve&lastname=ward&ip=111.111.111.111&url=ss-corp.com.com

project currently written in php. would like to use FoxPro to post data from the table and record the results.

I still don't understand how the get would work as to where i would place each of the vailiable to be passed...however on the post side i have created the following...it works (meaning runs without error) however no data was posted to the table on the receiving end.


LOCAL loHttp
LOCAL lnSuccess
LOCAL loReq
LOCAL loResp
loHttp = CreateObject('Chilkat.Http')
  Any string unlocks the component for the 1st 30-days.
lnSuccess = loHttp.UnlockComponent("**")
IF (lnSuccess <> 1) THEN
    ? loHttp.LastErrorText
    QUIT
ENDIF
loReq = CreateObject('Chilkat.HttpRequest')
  Add the request params expected by the server-side:
loReq.AddParam("cid","1010")
loReq.AddParam("email","s.ward@ss-corp.com")
loReq.AddParam("firstname","Steve")
loReq.AddParam("lastname","Ward")
loReq.AddParam("ip","111.111.111.111")
loReq.AddParam("url","www.ss-corp.com")
loReq.AddParam("zip","33912")
loReq.AddParam("phonenumber","111-111-1111")
*  Send the POST  (This is a real URL that may be tested.)
loResp = loHttp.PostUrlEncoded("http://crg.ss-corp.com/live.asp",loReq)

asked Jun 25 '12 at 16:34

sward's gravatar image

sward
1112

edited Jun 26 '12 at 14:30

chilkat's gravatar image

chilkat ♦♦
3.4k110168241


If you wish to duplicate what the browser sends when you cut-and-paste the entire URL (above), including the params, into the browser's address textbox, then you would send a GET, not a POST. You would call http.QuickGetStr, as shown here: http://www.example-code.com/foxpro/http_get.asp

To send a POST, then create an HttpRequest object, add each of the params, and then call PostUrlEncoded, as shown here: http://www.example-code.com/foxpro/http_postUrlEncoded.asp (The URL passed to PostUrlEncoded would be "http://crg.ss-corp.com/live.asp", which is everything up to but not including the "?" from the URL above.

The difference between a GET and a POST is shown below:

This is the HTTP GET request sent by QuickGetStr:

GET /live.asp?cid=1012&email=test@ss-corp.com&firstname=steve&lastname=ward&ip=111.111.111.111&url=ss-corp.com.com HTTP/1.1
Accept: /
Accept-Encoding: gzip
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Language: en-us,en;q=0.5
User-Agent: Chilkat/1.0.0 (+http://www.chilkatsoft.com/ChilkatHttpUA.asp)
Host: crg.ss-corp.com
Connection: Keep-Alive

All HTTP requests are composed of a "start line" followed by a MIME message (i.e. MIME header + body). A GET request has an empty body and the params are provided in the "start line".

This is the POST request:


POST /live.asp HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: crg.ss-corp.com
Content-Length: 118

cid=1012&email=test%40ss%2Dcorp%2Ecom&firstname=steve&lastname=ward&ip=111%2E111%2E111%2E111&url=ss%2Dcorp%2Ecom%2Ecom

In a POST request, the path to the resource is provided on the "start line", and the params are passed in the body of the MIME. In this case, since the Content-Type is "x-www-form-urlencoded", the body contains the URL encoded params. The Content-Length header indicates the number of bytes in the body.

link

answered Jun 26 '12 at 08:50

chilkat's gravatar image

chilkat ♦♦
3.4k110168241

I still don't understand how the get would work as to where i would place each of the vailiable to be passed...however on the post side i have created the following...it works (meaning runs without error) however no data was posted to the table on the receiving end. z


LOCAL loHttp
LOCAL lnSuccess
LOCAL loReq
LOCAL loResp
loHttp = CreateObject('Chilkat.Http')
  Any string unlocks the component for the 1st 30-days.
lnSuccess = loHttp.UnlockComponent("**")
IF (lnSuccess <> 1) THEN
    ? loHttp.LastErrorText
    QUIT
ENDIF
loReq = CreateObject('Chilkat.HttpRequest')
  Add the request params expected by the server-side:
loReq.AddParam("cid","1010")
loReq.AddParam("email","s.ward@ss-corp.com")
loReq.AddParam("firstname","Steve")
loReq.AddParam("lastname","Ward")
loReq.AddParam("ip","111.111.111.111")
loReq.AddParam("url","www.ss-corp.com")
loReq.AddParam("zip","33912")
loReq.AddParam("phonenumber","111-111-1111")
*  Send the POST  (This is a real URL that may be tested.)
loResp = loHttp.PostUrlEncoded("http://crg.ss-corp.com/live.asp",loReq)

link

answered Jun 26 '12 at 13:29

sward's gravatar image

sward
1112

edited Jun 26 '12 at 14:22

chilkat's gravatar image

chilkat ♦♦
3.4k110168241

There are two ways to verify the POST.

  1. Set the SessionLogFilename property to the path of a log file you want created/appended. Then run your program, and afterwards examine the file in a text editor. You'll see the exact HTTP requests and responses.
  2. Change the URL passed in the 1st argument to PostUrlEncoded to "http://www.chilkatsoft.com/echoPost.asp". This classic ASP page will echo back the params it receives.

The classic ASP source for echoPost.asp looks like this:


    <html>
<body>

<%
for each x in Request.Form
Response.Write("<br>" & x & " = " & Request.Form(x))
next
%>

</body>
</html>

link

answered Jun 26 '12 at 14:29

chilkat's gravatar image

chilkat ♦♦
3.4k110168241

ok i added the 2 steps when I run it now with the http://www.chilkatsoft.com/echoPost.asp i get the following txt file


---- Sending ----
POST /echoPost.asp HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: www.chilkatsoft.com
Content-Length: 161

cid=1010&email=s%2Eward%40ss%2Dcorp%2Ecom&firstname=Steve&lastname=Ward&ip=111%2E111%2E111%2E111&url=www%2Ess%2Dcorp%2Ecom&zip=33912&phonenumber=111%2D111%2D1111

HTTP/1.1 200 OK Date: Tue, 26 Jun 2012 22:29:22 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Content-Length: 216 Content-Type: text/html Set-Cookie: ASPSESSIONIDCQQBSSCR=FABNAAHAJHJFFGLPIMPNJGMO; path=/ Cache-control: private

<html> <body>

<br>cid = 1010<br>email = s.ward@ss-corp.com<br>url = www.ss-corp.com&lt;br>firstname = Steve<br>lastname = Ward<br>phonenumber = 111-111-1111<br>ip = 111.111.111.111<br>zip = 33912

</body> </html>

However when using my url http://crg.ss-corp.com/live.asp i get no log file at all

link

answered Jun 26 '12 at 18:34

sward's gravatar image

sward
1112

edited Jun 26 '12 at 19:00

chilkat's gravatar image

chilkat ♦♦
3.4k110168241

This shows that the HTTP POST is being sent correctly. The problem is either on the server-side, or maybe the server side is expecting something different, in which case it's impossible for me to know what your server-side app might be expecting..

link

answered Jun 26 '12 at 18:58

chilkat's gravatar image

chilkat ♦♦
3.4k110168241

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×60
×13

Asked: Jun 25 '12 at 16:34

Seen: 924 times

Last updated: Jun 26 '12 at 19:00

powered by OSQA