How to GET (query string parameters)

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ChrisMukrow
Posts: 73
Joined: Mon Nov 12, 2012 4:13 pm

How to GET (query string parameters)

Post by ChrisMukrow » Mon Jan 26, 2015 12:08 pm

Is it possible to make a GET in Livecode, http://url.com/?id=10 (result: id=10), couldn't find it in the docs. Like $_GET in php?

Thanks,
Chris

Klaus
Posts: 13865
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to GET (query string parameters)

Post by Klaus » Mon Jan 26, 2015 3:17 pm

Hi Chris,

not being an internet expert, but isn't this a simple as:
...
put url "http://url.com/?id=10" into tResultData
...
Or if you prefer IT:
...
GET url "http://url.com/?id=10"
...
?


Best

Klaus

ChrisMukrow
Posts: 73
Joined: Mon Nov 12, 2012 4:13 pm

Re: How to GET (query string parameters)

Post by ChrisMukrow » Mon Jan 26, 2015 3:26 pm

Hi Klaus,

My message was a bit vague, sorry for that. The idea is: when you use php $_GET["id"] on this url http://url.com/?id=10, you get the variable from id (which is 10). I want to use this so I can combine html with Livecode.

Hope this makes it clear, thanks for your help!

Klaus
Posts: 13865
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to GET (query string parameters)

Post by Klaus » Mon Jan 26, 2015 5:35 pm

Hi Chris,

aha, but still not sure if this is now a real internet/url issue or a "simple" text chunk problem? :D
If the latter, you need to parse the string by yourself, maybe set the itemdelimiter to ? first?


Best

Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7258
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How to GET (query string parameters)

Post by jacque » Mon Jan 26, 2015 10:11 pm

If you're writing a server script, you can use $_GET or $_GET_RAW. There are a number of other "$_" functions in the dictionary that might be what you want too.

If you are writing a desktop app, the environment variables are available via the "$" function, but it doesn't seem likely that an app would be receiving URL requests. If the app is generating the URL then it already knows the values of the parameters.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

ChrisMukrow
Posts: 73
Joined: Mon Nov 12, 2012 4:13 pm

Re: How to GET (query string parameters)

Post by ChrisMukrow » Tue Jan 27, 2015 9:35 pm

Thanks Klaus and Jacque, I will try it with the itemdelimiter, thats good enough for now. And Jacque your right, it's an unlikely scenario. But I want to use precreated html files in app and combine these with native features.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7258
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How to GET (query string parameters)

Post by jacque » Tue Jan 27, 2015 10:34 pm

Okay, I see. The usual way to parse out query string values is to split the query portion of the URL into an array like this:

Code: Select all

put char offset("?",tURL)+1 to -1 of tURL into tQuery
split tQuery by "&" and "="
Now you have an array with the variables as keys and the elements as their values.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

ChrisMukrow
Posts: 73
Joined: Mon Nov 12, 2012 4:13 pm

Re: How to GET (query string parameters)

Post by ChrisMukrow » Fri Jan 30, 2015 11:35 am

Thanks Jacque! Will give it a try.

Post Reply

Return to “iOS Deployment”