How to GET (query string parameters)
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 73
- Joined: Mon Nov 12, 2012 4:13 pm
How to GET (query string parameters)
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
Thanks,
Chris
Re: How to GET (query string parameters)
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
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
-
- Posts: 73
- Joined: Mon Nov 12, 2012 4:13 pm
Re: How to GET (query string parameters)
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!
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!
Re: How to GET (query string parameters)
Hi Chris,
aha, but still not sure if this is now a real internet/url issue or a "simple" text chunk problem?
If the latter, you need to parse the string by yourself, maybe set the itemdelimiter to ? first?
Best
Klaus
aha, but still not sure if this is now a real internet/url issue or a "simple" text chunk problem?
If the latter, you need to parse the string by yourself, maybe set the itemdelimiter to ? first?
Best
Klaus
-
- 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)
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.
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
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 73
- Joined: Mon Nov 12, 2012 4:13 pm
Re: How to GET (query string parameters)
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.
-
- 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)
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:
Now you have an array with the variables as keys and the elements as their values.
Code: Select all
put char offset("?",tURL)+1 to -1 of tURL into tQuery
split tQuery by "&" and "="
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 73
- Joined: Mon Nov 12, 2012 4:13 pm
Re: How to GET (query string parameters)
Thanks Jacque! Will give it a try.