Page 1 of 1

Auto Detect Location For Weather

Posted: Thu Sep 14, 2017 5:23 am
by proloy
Hello,
Again I am here with new quarry! Last time “Jilm” solved my problem.
I like to add Auto Detect Location and put latitude, longitude in Dark Sky API. This is a desktop client for casparCG.
My Button code is below:

Code: Select all

 on mouseUp
   put the text of fld "city" into tCityName
   put the text of fld "country" into tCountry
   put "?units=si" into si
   
   
put "[https]://api.darksky.[net]/forecast/f75094a5a6e929acb6e7274f363dadab/23.727785,90.413495"&si into tURL
put URL tURL into tRawJSON
put textDecode(tRawJSON,"UTF8") into fld "weatherdata"
put arrayFromJson(tRawJSON) into tArray

put tArray["currently"]["summary"] into fld "Status"
put tArray["currently"]["temperature"] into fld "Temp"
put tArray["currently"]["apparentTemperature"] into fld "RealFeels"
put tArray["currently"]["windSpeed"] into fld "WindSpeed"
put tArray["currently"]["humidity"] into fld "Humidity"

end mouseUp
As a fresher I always follow and read forum senior members post/suggestions. I have search a lot and google it, but no luck.

Please advice..

Re: Auto Detect Location For Weather

Posted: Thu Sep 14, 2017 12:14 pm
by Klaus
Hi proloy,

I am missing your question! :D

OK, use the correct syntax and it will work fine:
...
put URL tURL into tRawJSON
put textDecode(tRawJSON,"UTF8") into fld "weatherdata"
## put arrayFromJson(tRawJSON) into tArray
put JSONtoArray(tRawJSON) into tArray
...
Hint: the dictionary is your friend!


Best

Klaus

Re: Auto Detect Location For Weather

Posted: Sat Sep 16, 2017 3:53 am
by proloy
@klaus, thanks for your reply.
Actually, i like to know: is there any way to get "Auto detect Current location, latitude & longitude data" without GPS. i am going to use this data in darksky API (latitude, longitude) position.

I already share my weather Button code, as you can understand what i want to do :)

Thanks.

Re: Auto Detect Location For Weather

Posted: Thu Sep 21, 2017 1:02 pm
by MaxV
You can try: http://freegeoip.net or https://www.geoiptool.com/
but I don't know how much is accurate.

Best regards
Max