URL encode post to web

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
reelstuff
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 254
Joined: Mon Apr 16, 2007 12:06 am
Contact:

URL encode post to web

Post by reelstuff » Tue Apr 09, 2013 1:04 am

I have a basic example of a method of posting to a server online, in the following manner.

Code: Select all

username=_YOUR_ACCOUNT_USERNAME_&pass=_YOUR_ACCOUNT_PASSWORD_&XXid=_XX_ID_&message=_MESSSAGE_&topics=_COMMA_SEPARATED_TOPIC_NAMES
So if I were to use the

Code: Select all

#URLEncode method would it work something like this?

put tURL into my_new_URL_Var

URLEncode my_new_URL_Var

put it into eURL

post eURL

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: URL encode post to web

Post by Simon » Tue Apr 09, 2013 1:10 am

Hi reelstuff,
What is your question?
(tip: they normally are followed by this "?" symbol). :D

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: URL encode post to web

Post by sturgis » Tue Apr 09, 2013 1:15 am

In this case, you need to urlencode the data only. You need to leave the = signs alone, and urlencode will mess with them.

If you are working on the desktop, probably the easiest way to accomplish your goal is to use the liburlformdata() function. It takes arguments in sets of 2, separated by comma.

so from your example something like this:

Code: Select all

put libUrlFormData("username","YOUR_ACCOUNT_USERNAME","pass","YOUR_ACCOUNT_PASSWORD","id","_XX_ID_","message","_message_","topics","TOPIC NAMES") into tData

post tData to url "http://your.url.com/whatever.php"
If your data is in variable names you can use those instead of a directly typed string like I did...
So instead of "YourAccountNameBlahBlah"
just put in tUsername

And as you can see above, you POST the data TO the url.

reelstuff
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 254
Joined: Mon Apr 16, 2007 12:06 am
Contact:

Re: URL encode post to web

Post by reelstuff » Tue Apr 09, 2013 1:48 am

Edit,

after playing around with URLEncode, and setting variables, I ran into something rather strange, it appears that messages are not being passed between scripts, in the same control or card script, it has been some time since I have used LC, but this seems like an odd way to behave as well, it appears that the focus is moving to the inspector instead of the card as it should perhaps a reboot is in order, hmmm,

Post Reply