West Wind Internet and Client Tools
How to use HTTPGet()
Gravatar is a globally recognized avatar based on your email address. How to use HTTPGet()
  Bruce Rowe
  All
  Dec 20, 2018 @ 11:31pm

Using HTTPGet

I was delighted to discover this function in the West-wind functions. I am using version 5.51 of the Client tools. It does not seem to be posting any data. For the result of this function, I get a blank. And, there is no email sent.

Here is the code I am using:

local lnResult, lnConnection
cVenue		= "Bruce's computer - "
cAPI		= "qzhmHMDxiDCm4n2iuTdH"
cText 		= '9876543210'

set procedure to .\wwclient\wwHttp additive
set procedure to .\wwClient\wwUtils additive

if vartype(oHTTP) # "O"
	oHTTP = createobject("wwHTTP")
	oHTTP.nConnectTimeout = 30	&& Make sure we wait! Let the server fail!
	oHTTP.nHTTPConnectType = 0
endif

*** Connect to the server
lnConnection = oHTTP.HTTPConnect('https://centerstage.com')

*** Let's post some data TO the server
oHTTP.AddPostKey('note', cText )
oHTTP.AddPostKey('apikey', cAPI )
oHTTP.AddPostKey('venue', cVenue )

*** Send the POST data and retrieve HTTP result
lcResult=oHTTP.HTTPGet('/postings/giftcard.php')

messagebox(lcResult,0,'Success')

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * / The function I am calling is a simple function to email me the variables I should have sent. This does not return anything: / giftcard.php */

<?php
{
	$to		= "centerstagesoftware@gmail.com";
	$subject	= $_POST['venue'] . " - " . $_SERVER['REMOTE_ADDR'];
	$body		= 'Note ' . $_POST['note'] . '<br>' . 'API key ' . $_POST['apikey'] ;
	$headers	= "centerstagesoftware@gmail.com";
	$mailresult	= mail( $to, $subject, $body,$headers );
}
?>

Does anyone know what is going wrong?

Gravatar is a globally recognized avatar based on your email address. re: How to use HTTPGet()
  Rick Strahl
  Bruce Rowe
  Dec 21, 2018 @ 01:45pm

Remove the call to .HttpConnect() - that's not needed with HttpGet() and likely screwing up the send operation.

Otherwise this looks right to me, but I can't vouch for your PHP code... 😃

Also - you should always recreate the HTTP object and not reuse the instance. HTTP connections are stateless and if you reuse you have to ensure you cleanup the request state for some things. Always better to use fresh instances.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: How to use HTTPGet()
  Bruce Rowe
  Bruce Rowe
  Dec 21, 2018 @ 02:17pm

It works! Thanks Rick

© 1996-2019