Page 1 of 1

How do i use Dark Sky API with livecode?

Posted: Sat Mar 11, 2017 6:41 pm
by jolleboi
Hey Guys
I am a beginner with livecode and i can't for the life of me figure out how to call for the API and use the data that it gives me. I have integrated the easyjson script in my stack and pasted the:

" $_GET url "

and i get nothing. I am probably missing alot but i don't know how to get it to work, i've googled alot and to be honest there isn't that much about livecode stuff...

My goal is to create a weather app

Re: How do i use Dark Sky API with livecode?

Posted: Sun Mar 12, 2017 5:11 am
by shaosean
Post some links to what you're talking about, so we can take a look..

Re: How do i use Dark Sky API with livecode?

Posted: Sun Mar 12, 2017 1:17 pm
by jolleboi
I wanna use the API from here darksky(dot)net/dev/docs/forecast and i dont know how to "call" for the data it has available

Re: How do i use Dark Sky API with livecode?

Posted: Sun Mar 12, 2017 11:59 pm
by ClipArtGuy
This should get you started. You won't need easyJSON, because the newer JSONimport function works just great. Just replace YOUR KEY HERE with your secret key from darksky and throw this script into button.

Code: Select all

on mouseUp
   get url "https://api.darksky.net/forecast/YOUR KEY HERE/42.3601,-71.0589"
   put it into tForecast  
   put JSONimport(tForecast) into tForecastArray
   answer "It is currently"&&tforecastarray[currently][temperature]&&"degrees and"&&tforecastarray[currently][summary]
end mouseUp

Re: How do i use Dark Sky API with livecode?

Posted: Mon Mar 13, 2017 11:36 am
by jolleboi
ClipArtGuy wrote:This should get you started. You won't need easyJSON, because the newer JSONimport function works just great. Just replace YOUR KEY HERE with your secret key from darksky and throw this script into button.

Code: Select all

on mouseUp
   get url "https://api.darksky(dot)net/forecast/YOUR KEY HERE/42.3601,-71.0589"
   put it into tForecast  
   put JSONimport(tForecast) into tForecastArray
   answer "It is currently"&&tforecastarray[currently][temperature]&&"degrees and"&&tforecastarray[currently][summary]
end mouseUp
Oh thank you this is great, i've been trying to get it to show directy on the screen with

on start

end start

but yeah that didnt work, how do i make it show right on the card all the time and not just in a pop up window when i click on a button?

Thanks again mate!

Re: How do i use Dark Sky API with livecode?

Posted: Mon Mar 13, 2017 2:15 pm
by shaosean
put it in to a field

Re: How do i use Dark Sky API with livecode?

Posted: Mon Mar 13, 2017 6:08 pm
by Klaus
Hi jolleboi,

1. welcome to the forum! :D

2. Looks like you could need some basics about LC, check these great learning resources:
http://www.hyperactivesw.com/revscriptc ... ences.html

Best

Klaus