Servicio meteorológico

Servicio meteorológico

Postby armando.lagunas » Tue Dec 02, 2014 12:28 pm

Estimados:

Es posible mostrar este servicio en una aplicación de FiveWin a través de un servicio gratuito?. como lo hacen los teléfonos celulares?
tengo la necesidad de realizar esto, debido a que se debe planificar la cosecha del huerto, según este el tiempo en la zona del productor.
He buscado y no encuentro nada relacionado con este tema.

alguna sugerencia?

desde ya muchas gracias

Armando.
SkyPe: armando.lagunas@hotmail.com
Mail: armando.lagunas@gmail.com
User avatar
armando.lagunas
 
Posts: 346
Joined: Mon Oct 05, 2009 3:35 pm
Location: Curico-Chile

Re: Servicio meteorológico

Postby mastintin » Tue Dec 02, 2014 10:15 pm

N sé si es esto exactamente lo que necesitas pero te pongo un código ( sin terminar ) que he realizado .
Lo que hace es llamar a una dirección de yahoo weather donde le pasa unos parámetros , entre ellos la ciudad o el formato de respuesta ( xml o Json )
recogemos la respuesta y podemos grabarla o no según nos guste. Esa respuesta se puede tratar para extraerle los datos . En el ejemplo recoge un son y lo trato para sacar los datos que me interesan y los muestro en un msginfo ...
Espero sea lo que buscas.

Code: Select all  Expand view

// Our first DialogBox sample

#include "FiveWin.ch"

function Main()

   local oDlg, oIco ,cCity:= space(30)

   DEFINE ICON oIco FILE "..\icons\fivewin.ico"

   DEFINE DIALOG oDlg TITLE "Ciudad a buscar" COLOR "W+/B" ;
      ICON oIco


     @ 1, 3 GET cCity

     @ 3, 5 BUTTON "&Ok" SIZE 40, 12 ;
      ACTION llamada(cCity)

   @ 3, 16 BUTTON "&Cancel" SIZE 40, 12 ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED ;
      VALID MsgYesNo( "Do you want to end ?" )

return nil

procedure AppSys // XBase++ requirement

return


Function llamada(cCity)
local oHttp
local cResp
local cDir
local Formato :=  "json"  // "xml"  


cDir := "https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid in (select woeid from geo.places(1)"
cDir:= cDir + " where text= '"+ cCity +"' )&format=" + Formato



 
 Try
      oHttp := CreateObject("winhttp.winhttprequest.5.1")
      oHttp:Open("GET", cDir, .f. )
      oHttp:Send()
      cResp := oHttp:ResponseText()
      memowrit("eltiempo.txt",cResp )
     // msginfo("grabado")
     // winexec( "notepad.exe eltiempo.txt" )
     leejson( cResp )
   Catch
      MsgStop( "Error" )
      Return cResp
   End Try


Return nil


function Leejson(cResp )
local hvar
local hvar1,hvar2
local cTexto:=""

//msginfo(cResp )
hb_jsondecode(cResp,@hvar  )

cTexto := "Fecha : "+ hvar["query"]["created"]+CRLF

hvar1:= hvar["query"]["results"]["channel"]

cTexto:= cTexto+  hvar1["title"] + CRLF
cTexto:= cTexto + "Viento" + CRLF

hvar2:= hvar1["wind"]

cTexto:= cTexto + "Chill "+ hVar2["chill"] + CRLF
cTexto:= cTexto + "Direcccion "+ hVar2["direction"] + CRLF
cTexto:= cTexto + "Velocidad "+ hVar2["speed"]+ hvar1["units"]["speed"] + CRLF

/*
asi se puede seguir despiezando el json

*/


msginfo( cTexto,"Titulo" )

 return nil

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Servicio meteorológico

Postby Silvio.Falconi » Wed Dec 03, 2014 8:10 am

I tried your test with Rome a city of Italy
and it return error
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: Servicio meteorológico

Postby mastintin » Wed Dec 03, 2014 9:07 am

Silvio , aqui funciona bien :
Image

El error se produce seguro en el troceado del archivo json que será distinto desde mi localización respecto a la tuya.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Servicio meteorológico

Postby Silvio.Falconi » Wed Dec 03, 2014 9:59 am

Perhaps here I have a proxy..firewall
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: Servicio meteorológico

Postby mastintin » Wed Dec 03, 2014 10:43 am

silvio , puedes añadir a tu codigo y dinos si funciona :
Code: Select all  Expand view


cProxi:= "192.10.1.1:8080" // tu configuracion proxi .
oHttp:SetProxy( HTTPREQUEST_PROXYSETTING_PROXY,cProxi  )

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Servicio meteorológico

Postby armando.lagunas » Wed Dec 03, 2014 12:03 pm

muchas gracias por responder

con lo que me indicas puedo empezar. :D :D :D



gracias desde Chile
SkyPe: armando.lagunas@hotmail.com
Mail: armando.lagunas@gmail.com
User avatar
armando.lagunas
 
Posts: 346
Joined: Mon Oct 05, 2009 3:35 pm
Location: Curico-Chile


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: karinha and 83 guests