post url newbie

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
gwbasic
Posts: 34
Joined: Tue Mar 16, 2010 6:39 am

post url newbie

Post by gwbasic » Tue Mar 16, 2010 6:52 am

I'm trying to convert the code below to Rev:

~~~~~~~~~~~
OleObject ie
integer li_rc
string s, msg, q

q = "select * from status"

ie = CREATE OleObject
li_rc = ie.ConnectToNewObject( "Microsoft.XMLHTTP" )

ie.open( "POST", "http://test/query_test.php", False )
ie.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded")

s = URLEncode( q )

TRY
ie.send( "query=" + s)
CATCH (RuntimeError ErrPrint)
MessageBox("ERROR",ErrPrint.GetMessage() )
END TRY

If ie.readyState <> 4 then
msg = "Failed"
else
msg = string(ie.responseText)
end if

MessageBox("HTTP Response", msg)

destroy ie
~~~~~~

but the example in the dictionary is incomplete:

post myData to URL "http://www.example.net/indications.cgi"
post field "Return Values" to URL field "Current Page"

I need to pass the query string to php page "query=" + s. Please help.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: post url newbie

Post by BvG » Tue Mar 16, 2010 5:11 pm

It's not incomplete. your query goes into the "myData" part of the first example.

for example

Code: Select all

put "blahblah" into myQuery
urlencode(myQuery)
post myQUery to url "http://someurlthatimadeup.justnow"
put the result && it
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

gwbasic
Posts: 34
Joined: Tue Mar 16, 2010 6:39 am

Re: post url newbie

Post by gwbasic » Wed Mar 17, 2010 12:48 am

Thanks.

gwbasic
Posts: 34
Joined: Tue Mar 16, 2010 6:39 am

Re: post url newbie

Post by gwbasic » Fri Aug 13, 2010 1:56 am

I'm trying to do this:

put "id_no=100" into myQuery
urlencode(myQuery)
post myQUery to url "http://localhost"
put the result && it

I already have web server set up (xampp) with a php service handler. My php handler looks like this:

if ( isset($_REQUEST['id_no']) ) {
print "ok<b>" ;
}
else
{
print "NOT ok<b>" ;
}

But I keep getting NOT ok. So how do set the POST variable "id_no"?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: post url newbie

Post by Mark » Fri Aug 13, 2010 8:39 am

Hi gwbasic,

Don't urlEncode "id_no=100" in its entirety. Instead, just urlEncode "100".

put "id_no=" & urlEncode("100") into myQuery

This will leave "100" unaffected, but when you are going to use more complex strings, encoding the data will appear useful. Don't encode the variable names and the "=" signs. Encode the data only.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

gwbasic
Posts: 34
Joined: Tue Mar 16, 2010 6:39 am

Re: post url newbie

Post by gwbasic » Fri Aug 13, 2010 9:40 am

Thank you very much!

gwbasic
Posts: 34
Joined: Tue Mar 16, 2010 6:39 am

Re: post url newbie

Post by gwbasic » Tue Aug 17, 2010 9:15 am

post myQUery to url "https://localhost"

will the code above work with https?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: post url newbie

Post by Mark » Tue Aug 17, 2010 9:30 am

gwbasic,

Have you read the documentation about the https keyword and tried it?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply